| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <cstring> | ||
| 2 | #include <stdio.h> | ||
| 3 | #include "base/zc_alleg.h" | ||
| 4 | #include "zc/guys.h" | ||
| 5 | #include "zc/replay.h" | ||
| 6 | #include "zc/zc_ffc.h" | ||
| 7 | #include "zc/zelda.h" | ||
| 8 | #include "base/zsys.h" | ||
| 9 | #include "base/msgstr.h" | ||
| 10 | #include "zc/maps.h" | ||
| 11 | #include "zc/hero.h" | ||
| 12 | #include "subscr.h" | ||
| 13 | #include "zc/ffscript.h" | ||
| 14 | #include "gamedata.h" | ||
| 15 | #include "defdata.h" | ||
| 16 | #include "zscriptversion.h" | ||
| 17 | #include "particles.h" | ||
| 18 | #include "base/zc_math.h" | ||
| 19 | #include "slopes.h" | ||
| 20 | #include "base/qrs.h" | ||
| 21 | #include "base/dmap.h" | ||
| 22 | #include "base/mapscr.h" | ||
| 23 | #include "base/misctypes.h" | ||
| 24 | #include "base/initdata.h" | ||
| 25 | #include "zc/combos.h" | ||
| 26 | extern particle_list particles; | ||
| 27 | |||
| 28 | extern FFScript FFCore; | ||
| 29 | extern ZModule zcm; | ||
| 30 | extern HeroClass Hero; | ||
| 31 | extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations; | ||
| 32 | |||
| 33 | int32_t repaircharge=0; | ||
| 34 | bool adjustmagic=false; | ||
| 35 | bool learnslash=false; | ||
| 36 | int32_t wallm_load_clk=0; | ||
| 37 | int32_t sle_x,sle_y,sle_cnt,sle_clk=0; | ||
| 38 | int32_t vhead=0; | ||
| 39 | int32_t guycarryingitem=0; | ||
| 40 | |||
| 41 | char *guy_string[eMAXGUYS]; | ||
| 42 | |||
| 43 | void never_return(int32_t index); | ||
| 44 | void playLevelMusic(); | ||
| 45 | |||
| 46 | // If an enemy is this far out of the playing field, just remove it. | ||
| 47 | #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512) | ||
| 48 | //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767) | ||
| 49 | #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14) | ||
| 50 | #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15) | ||
| 51 | |||
| 52 | 29260 | void do_fix(zfix& coord, int32_t val, bool nearest_half = false) | |
| 53 | { | ||
| 54 | 29260 | int32_t c = coord.getInt(); | |
| 55 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 29260 times.
|
29260 | if(nearest_half) |
| 56 | { | ||
| 57 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 29260 times.
|
29260 | if (c < 0) |
| 58 | ✗ | c -= val / 2; | |
| 59 | 29260 | else c += (val/2); | |
| 60 | 29260 | } | |
| 61 | 29260 | c -= c % val; | |
| 62 | 29260 | coord = c; | |
| 63 | 29260 | } | |
| 64 | |||
| 65 | ✗ | bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z) | |
| 66 | { | ||
| 67 | ✗ | return | |
| 68 | ( | ||
| 69 | ✗ | (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2]) | |
| 70 | ✗ | || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1]) | |
| 71 | ✗ | || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1]) | |
| 72 | ✗ | || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2]) | |
| 73 | ✗ | || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1]) | |
| 74 | ✗ | || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2]) | |
| 75 | ); | ||
| 76 | } | ||
| 77 | |||
| 78 | namespace | ||
| 79 | { | ||
| 80 | int32_t trapConstantHorizontalID; | ||
| 81 | int32_t trapConstantVerticalID; | ||
| 82 | int32_t trapLOSHorizontalID; | ||
| 83 | int32_t trapLOSVerticalID; | ||
| 84 | int32_t trapLOS4WayID; | ||
| 85 | |||
| 86 | int32_t cornerTrapID; | ||
| 87 | int32_t centerTrapID; | ||
| 88 | |||
| 89 | int32_t rockID; | ||
| 90 | int32_t zoraID; | ||
| 91 | int32_t statueID; | ||
| 92 | } | ||
| 93 | |||
| 94 | 282 | void identifyCFEnemies() | |
| 95 | { | ||
| 96 | 282 | trapConstantHorizontalID=-1; | |
| 97 | 282 | trapConstantVerticalID=-1; | |
| 98 | 282 | trapLOSHorizontalID=-1; | |
| 99 | 282 | trapLOSVerticalID=-1; | |
| 100 | 282 | trapLOS4WayID=-1; | |
| 101 | 282 | cornerTrapID=-1; | |
| 102 | 282 | centerTrapID=-1; | |
| 103 | 282 | rockID=-1; | |
| 104 | 282 | zoraID=-1; | |
| 105 | 282 | statueID=-1; | |
| 106 | |||
| 107 |
2/2✓ Branch 0 taken 144384 times.
✓ Branch 1 taken 282 times.
|
144666 | for(int32_t i=0; i<eMAXGUYS; i++) |
| 108 | { | ||
| 109 |
3/4✓ Branch 0 taken 278 times.
✓ Branch 1 taken 144106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
|
144384 | if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1) |
| 110 | 278 | trapLOSHorizontalID=i; | |
| 111 |
4/4✓ Branch 0 taken 288 times.
✓ Branch 1 taken 144096 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 282 times.
|
144384 | if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1) |
| 112 | 282 | trapLOSVerticalID=i; | |
| 113 |
3/4✓ Branch 0 taken 282 times.
✓ Branch 1 taken 144102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
|
144384 | if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1) |
| 114 | 282 | trapLOS4WayID=i; | |
| 115 |
3/4✓ Branch 0 taken 282 times.
✓ Branch 1 taken 144102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
|
144384 | if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1) |
| 116 | 282 | trapConstantHorizontalID=i; | |
| 117 |
3/4✓ Branch 0 taken 282 times.
✓ Branch 1 taken 144102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
|
144384 | if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1) |
| 118 | 282 | trapConstantVerticalID=i; | |
| 119 | |||
| 120 |
3/4✓ Branch 0 taken 282 times.
✓ Branch 1 taken 144102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
|
144384 | if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1) |
| 121 | 282 | cornerTrapID=i; | |
| 122 |
3/4✓ Branch 0 taken 282 times.
✓ Branch 1 taken 144102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
|
144384 | if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1) |
| 123 | 282 | centerTrapID=i; | |
| 124 | |||
| 125 |
3/4✓ Branch 0 taken 282 times.
✓ Branch 1 taken 144102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
|
144384 | if((guysbuf[i].flags2&eneflag_rock) && rockID==-1) |
| 126 | 282 | rockID=i; | |
| 127 |
4/4✓ Branch 0 taken 292 times.
✓ Branch 1 taken 144092 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 281 times.
|
144384 | if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1) |
| 128 | 281 | zoraID=i; | |
| 129 | |||
| 130 |
4/4✓ Branch 0 taken 309 times.
✓ Branch 1 taken 144075 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 282 times.
|
144384 | if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1) |
| 131 | 282 | statueID=i; | |
| 132 | 144384 | } | |
| 133 | 282 | } | |
| 134 | |||
| 135 | ✗ | int32_t random_layer_enemy() | |
| 136 | { | ||
| 137 | ✗ | int32_t cnt=count_layer_enemies(); | |
| 138 | |||
| 139 | ✗ | if(cnt==0) | |
| 140 | { | ||
| 141 | ✗ | return eNONE; | |
| 142 | } | ||
| 143 | |||
| 144 | ✗ | int32_t ret=zc_oldrand()%cnt; | |
| 145 | ✗ | cnt=0; | |
| 146 | |||
| 147 | ✗ | for(int32_t i=0; i<6; ++i) | |
| 148 | { | ||
| 149 | ✗ | if(tmpscr->layermap[i]!=0) | |
| 150 | { | ||
| 151 | ✗ | mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i]; | |
| 152 | |||
| 153 | ✗ | for(int32_t j=0; j<10; ++j) | |
| 154 | { | ||
| 155 | ✗ | if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS) | |
| 156 | { | ||
| 157 | ✗ | if(cnt==ret) | |
| 158 | { | ||
| 159 | ✗ | return layerscreen->enemy[j]; | |
| 160 | } | ||
| 161 | |||
| 162 | ✗ | ++cnt; | |
| 163 | ✗ | } | |
| 164 | ✗ | } | |
| 165 | ✗ | } | |
| 166 | ✗ | } | |
| 167 | |||
| 168 | ✗ | return eNONE; | |
| 169 | ✗ | } | |
| 170 | |||
| 171 | ✗ | int32_t count_layer_enemies() | |
| 172 | { | ||
| 173 | ✗ | int32_t cnt=0; | |
| 174 | |||
| 175 | ✗ | for(int32_t i=0; i<6; ++i) | |
| 176 | { | ||
| 177 | ✗ | if(tmpscr->layermap[i]!=0) | |
| 178 | { | ||
| 179 | ✗ | mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i]; | |
| 180 | |||
| 181 | ✗ | for(int32_t j=0; j<10; ++j) | |
| 182 | { | ||
| 183 | ✗ | if(layerscreen->enemy[j]!=0) | |
| 184 | { | ||
| 185 | ✗ | ++cnt; | |
| 186 | ✗ | } | |
| 187 | ✗ | } | |
| 188 | ✗ | } | |
| 189 | ✗ | } | |
| 190 | |||
| 191 | ✗ | return cnt; | |
| 192 | } | ||
| 193 | |||
| 194 | 5087 | int32_t hero_on_wall() | |
| 195 | { | ||
| 196 | 5087 | zfix lx = Hero.getX(); | |
| 197 | 5087 | zfix ly = Hero.getY(); | |
| 198 | |||
| 199 | |||
| 200 | //zprint2("hero_on_wall x is: %d\n", lx); | ||
| 201 | //zprint2("hero_on_wall y is: %d\n", ly); | ||
| 202 | |||
| 203 |
4/4✓ Branch 0 taken 4511 times.
✓ Branch 1 taken 576 times.
✓ Branch 2 taken 143 times.
✓ Branch 3 taken 4368 times.
|
5087 | if(lx>=48 && lx<=192) |
| 204 | { | ||
| 205 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4358 times.
|
4368 | if(ly==32) return up+1; |
| 206 | |||
| 207 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4350 times.
|
4358 | if(ly==128) return down+1; |
| 208 | 4350 | } | |
| 209 | |||
| 210 |
4/4✓ Branch 0 taken 4697 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 408 times.
✓ Branch 3 taken 4289 times.
|
5069 | if(ly>=48 && ly<=112) |
| 211 | { | ||
| 212 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4279 times.
|
4289 | if(lx==32) return left+1; |
| 213 | |||
| 214 |
2/2✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 1 times.
|
4279 | if(lx==208) return right+1; |
| 215 | 4278 | } | |
| 216 | |||
| 217 | 5058 | return 0; | |
| 218 | 5087 | } | |
| 219 | |||
| 220 | 16791 | bool tooclose(int32_t x,int32_t y,int32_t d) | |
| 221 | { | ||
| 222 |
2/2✓ Branch 0 taken 12849 times.
✓ Branch 1 taken 3942 times.
|
16791 | return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d); |
| 223 | } | ||
| 224 | |||
| 225 | 84025 | bool enemy::overpit(enemy *e) | |
| 226 | { | ||
| 227 | // This function (and shadow_overpit) has been broken since it was written, and only | ||
| 228 | // checked the same diagonal of the hitbox, over and over again. The bug is because both | ||
| 229 | // loops used the same variable name. | ||
| 230 | // Checking literally every pixel seems like overkill, so for now let's continue to | ||
| 231 | // do the single diagonal but just once. That's why the outer loop is commented out. | ||
| 232 | |||
| 233 | // for ( int32_t q = 0; q < hxsz; ++q ) | ||
| 234 | { | ||
| 235 |
2/2✓ Branch 0 taken 762077 times.
✓ Branch 1 taken 81124 times.
|
843201 | for ( int32_t q = 0; q < hit_height; ++q ) |
| 236 | { | ||
| 237 | //check every pixel of the hitbox | ||
| 238 |
2/2✓ Branch 0 taken 2901 times.
✓ Branch 1 taken 759176 times.
|
762077 | if ( ispitfall(x+q+hxofs, y+q+hyofs) ) |
| 239 | { | ||
| 240 | //if the hitbox is over a pit, we can't land | ||
| 241 | 2901 | return true; | |
| 242 | } | ||
| 243 | 759176 | } | |
| 244 | } | ||
| 245 | 81124 | return false; | |
| 246 | 84025 | } | |
| 247 | |||
| 248 | 139247 | bool enemy::shadow_overpit(enemy *e) | |
| 249 | { | ||
| 250 | // for ( int32_t q = 0; q < hxsz; ++q ) | ||
| 251 | { | ||
| 252 |
2/2✓ Branch 0 taken 2108900 times.
✓ Branch 1 taken 135379 times.
|
2244279 | for ( int32_t q = 0; q < hit_height; ++q ) |
| 253 | { | ||
| 254 | //check every pixel of the hitbox | ||
| 255 |
2/2✓ Branch 0 taken 3868 times.
✓ Branch 1 taken 2105032 times.
|
2108900 | if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) ) |
| 256 | { | ||
| 257 | //if the hitbox is over a pit, we can't land | ||
| 258 | 3868 | return true; | |
| 259 | } | ||
| 260 | 2105032 | } | |
| 261 | } | ||
| 262 | 135379 | return false; | |
| 263 | 139247 | } | |
| 264 | |||
| 265 | // Returns true iff a combo type or flag precludes enemy movement. | ||
| 266 | 135697 | bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB) | |
| 267 | { | ||
| 268 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 135697 times.
|
135697 | if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false; |
| 269 | 135697 | int32_t c = COMBOTYPE(dx,dy); | |
| 270 |
4/4✓ Branch 0 taken 88314 times.
✓ Branch 1 taken 47383 times.
✓ Branch 2 taken 6232 times.
✓ Branch 3 taken 41151 times.
|
183080 | bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB)); |
| 271 |
3/6✓ Branch 0 taken 46671 times.
✓ Branch 1 taken 89026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46671 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
135697 | bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_qr(qr_DROWN)); |
| 272 |
4/6✓ Branch 0 taken 50003 times.
✓ Branch 1 taken 85694 times.
✓ Branch 2 taken 50003 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50003 times.
✗ Branch 5 not taken.
|
271394 | return c==cPIT || c==cPITB || c==cPITC || |
| 273 |
4/6✓ Branch 0 taken 50003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50003 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42879 times.
✓ Branch 5 taken 7124 times.
|
50003 | c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) || |
| 274 | // Block enemies type and block enemies flags | ||
| 275 |
2/2✓ Branch 0 taken 49971 times.
✓ Branch 1 taken 42847 times.
|
7124 | combo_class_buf[c].block_enemies&1 || |
| 276 |
3/4✓ Branch 0 taken 49971 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49941 times.
✓ Branch 3 taken 30 times.
|
49971 | MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY || |
| 277 |
2/4✓ Branch 0 taken 49941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49941 times.
✗ Branch 3 not taken.
|
49941 | MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY || |
| 278 | // Check for ladder-only combos which aren't dried water | ||
| 279 |
3/4✓ Branch 0 taken 585 times.
✓ Branch 1 taken 49356 times.
✓ Branch 2 taken 585 times.
✗ Branch 3 not taken.
|
99882 | (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) || |
| 280 | // Check for drownable water | ||
| 281 |
3/4✓ Branch 0 taken 9419 times.
✓ Branch 1 taken 40522 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9419 times.
|
49941 | (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false))); |
| 282 | 50003 | } | |
| 283 | |||
| 284 | // Returns true iff enemy is floating and blocked by a combo type or flag. | ||
| 285 | 177711 | bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB) | |
| 286 | { | ||
| 287 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 177711 times.
|
177711 | if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false; |
| 288 |
4/4✓ Branch 0 taken 157921 times.
✓ Branch 1 taken 19790 times.
✓ Branch 2 taken 3147 times.
✓ Branch 3 taken 16643 times.
|
197501 | bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB)); |
| 289 |
3/4✓ Branch 0 taken 158431 times.
✓ Branch 1 taken 19280 times.
✓ Branch 2 taken 19280 times.
✗ Branch 3 not taken.
|
196991 | bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB)); |
| 290 |
2/2✓ Branch 0 taken 22093 times.
✓ Branch 1 taken 155618 times.
|
333329 | return ((special==spw_floater)&& |
| 291 |
2/2✓ Branch 0 taken 155480 times.
✓ Branch 1 taken 138 times.
|
155618 | ((COMBOTYPE(dx,dy)==cNOFLYZONE)|| |
| 292 |
1/2✓ Branch 0 taken 155480 times.
✗ Branch 1 not taken.
|
155480 | (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)|| |
| 293 |
1/2✓ Branch 0 taken 155480 times.
✗ Branch 1 not taken.
|
155480 | (MAPFLAG(dx,dy)==mfNOENEMY)|| |
| 294 |
1/2✓ Branch 0 taken 155480 times.
✗ Branch 1 not taken.
|
155480 | (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)|| |
| 295 |
3/4✓ Branch 0 taken 143 times.
✓ Branch 1 taken 155337 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 143 times.
|
310960 | (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) || |
| 296 |
2/2✓ Branch 0 taken 155009 times.
✓ Branch 1 taken 471 times.
|
155480 | (pit_blocks && ispitfall(dx,dy)))); |
| 297 | 177711 | } | |
| 298 | // Returns true iff a combo type or flag precludes enemy movement. | ||
| 299 | 7529 | bool groundblocked(int32_t dx, int32_t dy, guydata const& gd) | |
| 300 | { | ||
| 301 | 7529 | int32_t c = COMBOTYPE(dx,dy); | |
| 302 | 7529 | bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK); | |
| 303 |
2/2✓ Branch 0 taken 239 times.
✓ Branch 1 taken 7290 times.
|
7529 | bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_qr(qr_DROWN); |
| 304 |
4/6✓ Branch 0 taken 7529 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7526 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 7526 times.
✗ Branch 5 not taken.
|
29701 | return c==cPIT || c==cPITB || c==cPITC || |
| 305 |
4/6✓ Branch 0 taken 7526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7324 times.
✓ Branch 5 taken 202 times.
|
7526 | c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) || |
| 306 | // Block enemies type and block enemies flags | ||
| 307 |
2/2✓ Branch 0 taken 7525 times.
✓ Branch 1 taken 7323 times.
|
202 | combo_class_buf[c].block_enemies&1 || |
| 308 |
3/4✓ Branch 0 taken 7525 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7523 times.
✓ Branch 3 taken 2 times.
|
7525 | MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY || |
| 309 |
2/4✓ Branch 0 taken 7523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7523 times.
✗ Branch 3 not taken.
|
7523 | MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY || |
| 310 | // Check for ladder-only combos which aren't dried water | ||
| 311 |
3/4✓ Branch 0 taken 41 times.
✓ Branch 1 taken 7482 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
|
15046 | (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) || |
| 312 | // Check for drownable water | ||
| 313 |
3/4✓ Branch 0 taken 281 times.
✓ Branch 1 taken 7242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 281 times.
|
7523 | (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true))); |
| 314 | } | ||
| 315 | |||
| 316 | // Returns true iff enemy is floating and blocked by a combo type or flag. | ||
| 317 | 385 | bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd) | |
| 318 | { | ||
| 319 |
2/2✓ Branch 0 taken 380 times.
✓ Branch 1 taken 5 times.
|
385 | bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL)); |
| 320 | 385 | bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK); | |
| 321 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
|
770 | return ((special==spw_floater)&& |
| 322 |
2/2✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1 times.
|
385 | ((COMBOTYPE(dx,dy)==cNOFLYZONE)|| |
| 323 |
1/2✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
|
384 | (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)|| |
| 324 |
1/2✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
|
384 | (MAPFLAG(dx,dy)==mfNOENEMY)|| |
| 325 |
1/2✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
|
384 | (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)|| |
| 326 |
3/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 379 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
|
768 | (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) || |
| 327 |
2/2✓ Branch 0 taken 379 times.
✓ Branch 1 taken 5 times.
|
384 | (pit_blocks && ispitfall(dx,dy)))); |
| 328 | } | ||
| 329 | |||
| 330 | /**********************************/ | ||
| 331 | /******* Enemy Base Class *******/ | ||
| 332 | /**********************************/ | ||
| 333 | |||
| 334 |
4/8✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3258 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3258 times.
✗ Branch 7 not taken.
|
6516 | enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite() |
| 335 | 3258 | { | |
| 336 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | x=X; |
| 337 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | y=Y; |
| 338 | 3258 | id=Id; | |
| 339 | 3258 | clk=Clk; | |
| 340 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | floor_y=y; |
| 341 | 3258 | ceiling=false; | |
| 342 | 3258 | fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0; | |
| 343 | 3258 | grumble = movestatus = posframe = timer = ox = oy = 0; | |
| 344 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
✓ Branch 2 taken 3258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3258 times.
✗ Branch 5 not taken.
|
3258 | yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2); |
| 345 | 3258 | did_armos=true; | |
| 346 | 3258 | script_spawned=false; | |
| 347 | |||
| 348 | 3258 | d = guysbuf + (id & 0xFFF); | |
| 349 | 3258 | hp = d->hp; | |
| 350 | 3258 | starting_hp = hp; | |
| 351 | // cs = d->cset; | ||
| 352 | //d variables | ||
| 353 | |||
| 354 | 3258 | flags=d->flags; | |
| 355 | 3258 | flags2=d->flags2; | |
| 356 | 3258 | s_tile=d->s_tile; //secondary (additional) tile(s) | |
| 357 | 3258 | family=d->family; | |
| 358 | 3258 | dcset=d->cset; | |
| 359 | 3258 | cs=dcset; | |
| 360 |
2/2✓ Branch 0 taken 902 times.
✓ Branch 1 taken 2356 times.
|
3258 | anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim; |
| 361 | 3258 | dp=d->dp; | |
| 362 | 3258 | wdp=d->wdp; | |
| 363 | 3258 | wpn=d->weapon; | |
| 364 | 3258 | wpnsprite = d-> wpnsprite; //2.6 -Z | |
| 365 | 3258 | rate=d->rate; | |
| 366 | 3258 | hrate=d->hrate; | |
| 367 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | dstep=d->step; |
| 368 | 3258 | homing=d->homing; | |
| 369 | 3258 | dmisc1=d->misc1; | |
| 370 | 3258 | dmisc2=d->misc2; | |
| 371 | 3258 | dmisc3=d->misc3; | |
| 372 | 3258 | dmisc4=d->misc4; | |
| 373 | 3258 | dmisc5=d->misc5; | |
| 374 | 3258 | dmisc6=d->misc6; | |
| 375 | 3258 | dmisc7=d->misc7; | |
| 376 | 3258 | dmisc8=d->misc8; | |
| 377 | 3258 | dmisc9=d->misc9; | |
| 378 | 3258 | dmisc10=d->misc10; | |
| 379 | 3258 | dmisc11=d->misc11; | |
| 380 | 3258 | dmisc12=d->misc12; | |
| 381 | 3258 | dmisc13=d->misc13; | |
| 382 | 3258 | dmisc14=d->misc14; | |
| 383 | 3258 | dmisc15=d->misc15; | |
| 384 | 3258 | dmisc16=d->misc16; | |
| 385 | 3258 | dmisc17=d->misc17; | |
| 386 | 3258 | dmisc18=d->misc18; | |
| 387 | 3258 | dmisc19=d->misc19; | |
| 388 | 3258 | dmisc20=d->misc20; | |
| 389 | 3258 | dmisc21=d->misc21; | |
| 390 | 3258 | dmisc22=d->misc22; | |
| 391 | 3258 | dmisc23=d->misc23; | |
| 392 | 3258 | dmisc24=d->misc24; | |
| 393 | 3258 | dmisc25=d->misc25; | |
| 394 | 3258 | dmisc26=d->misc26; | |
| 395 | 3258 | dmisc27=d->misc27; | |
| 396 | 3258 | dmisc28=d->misc28; | |
| 397 | 3258 | dmisc29=d->misc29; | |
| 398 | 3258 | dmisc30=d->misc30; | |
| 399 | 3258 | dmisc31=d->misc31; | |
| 400 | 3258 | dmisc32=d->misc32; | |
| 401 |
2/2✓ Branch 0 taken 61 times.
✓ Branch 1 taken 3197 times.
|
3258 | if (get_qr(qr_BROKEN_ATTRIBUTE_31_32)) |
| 402 | { | ||
| 403 | 3197 | dmisc31 = dmisc32; | |
| 404 | 3197 | dmisc32 = 0; | |
| 405 | 3197 | } | |
| 406 | 3258 | spr_shadow=d->spr_shadow; | |
| 407 | 3258 | spr_death=d->spr_death; | |
| 408 | 3258 | spr_spawn=d->spr_spawn; | |
| 409 | |||
| 410 |
2/2✓ Branch 0 taken 133578 times.
✓ Branch 1 taken 3258 times.
|
136836 | for(int32_t i=0; i<edefLAST255; i++) |
| 411 | 133578 | defense[i]=d->defense[i]; | |
| 412 | |||
| 413 | 3258 | bgsfx=d->bgsfx; | |
| 414 | 3258 | hitsfx=d->hitsfx; | |
| 415 | 3258 | deadsfx=d->deadsfx; | |
| 416 | 3258 | bosspal=d->bosspal; | |
| 417 | 3258 | parent_script_UID = 0; | |
| 418 | |||
| 419 | 3258 | frozentile = d->frozentile; | |
| 420 | |||
| 421 | 3258 | frozencset = d->frozencset; | |
| 422 | 3258 | frozenclock = 0; | |
| 423 |
2/2✓ Branch 0 taken 32580 times.
✓ Branch 1 taken 3258 times.
|
35838 | for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q]; |
| 424 | |||
| 425 |
2/2✓ Branch 0 taken 55386 times.
✓ Branch 1 taken 3258 times.
|
58644 | for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0; |
| 426 | //firesfx = 0; //t.b.a -Z | ||
| 427 | 3258 | isCore = true; //t.b.a | |
| 428 | 3258 | parentCore = 0; //t.b.a | |
| 429 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs. |
| 430 | |||
| 431 | 3258 | firesfx = d->firesfx; | |
| 432 |
2/2✓ Branch 0 taken 104256 times.
✓ Branch 1 taken 3258 times.
|
107514 | for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q]; |
| 433 |
2/2✓ Branch 0 taken 104256 times.
✓ Branch 1 taken 3258 times.
|
107514 | for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q]; |
| 434 | |||
| 435 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data. |
| 436 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data. |
| 437 | |||
| 438 |
2/2✓ Branch 0 taken 26064 times.
✓ Branch 1 taken 3258 times.
|
29322 | for ( int32_t q = 0; q < 8; q++ ) |
| 439 | { | ||
| 440 | 26064 | initD[q] = d->initD[q]; | |
| 441 | //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]); | ||
| 442 | 26064 | weap_initiald[q] = d->weap_initiald[q]; | |
| 443 | //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]); | ||
| 444 | //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]); | ||
| 445 | //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]); | ||
| 446 | 26064 | } | |
| 447 |
2/2✓ Branch 0 taken 6516 times.
✓ Branch 1 taken 3258 times.
|
9774 | for ( int32_t q = 0; q < 2; q++ ) |
| 448 | { | ||
| 449 | 6516 | initA[q] = d->initA[q]; | |
| 450 | 6516 | weap_initiala[q] = d->weap_initiala[q]; | |
| 451 | 6516 | } | |
| 452 | |||
| 453 | 3258 | stickclk = 0; | |
| 454 | 3258 | submerged = false; | |
| 455 | 3258 | didScriptThisFrame = false; | |
| 456 | 3258 | ffcactivated = 0; | |
| 457 | 3258 | hitdir = -1; | |
| 458 | 3258 | dialogue_str = 0; //set by spawn flags. | |
| 459 | 3258 | editorflags = d->editorflags; //set by Enemy Editor | |
| 460 | //Set the drawing flag for this sprite. | ||
| 461 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; } |
| 462 | |||
| 463 | |||
| 464 |
2/2✓ Branch 0 taken 3110 times.
✓ Branch 1 taken 148 times.
|
3258 | if(bosspal>-1) |
| 465 | { | ||
| 466 |
1/2✓ Branch 0 taken 148 times.
✗ Branch 1 not taken.
|
148 | loadpalset(csBOSS,pSprite(bosspal)); |
| 467 | 148 | } | |
| 468 | |||
| 469 |
2/2✓ Branch 0 taken 861 times.
✓ Branch 1 taken 2397 times.
|
3258 | if(bgsfx>-1) |
| 470 | { | ||
| 471 |
1/2✓ Branch 0 taken 861 times.
✗ Branch 1 not taken.
|
861 | cont_sfx(bgsfx); |
| 472 | 861 | } | |
| 473 | |||
| 474 |
2/2✓ Branch 0 taken 902 times.
✓ Branch 1 taken 2356 times.
|
3258 | if(get_qr(qr_NEWENEMYTILES)) |
| 475 | { | ||
| 476 | 902 | o_tile=d->e_tile; | |
| 477 | 902 | frate = d->e_frate; | |
| 478 | 902 | } | |
| 479 | else | ||
| 480 | { | ||
| 481 | 2356 | o_tile=d->tile; | |
| 482 | 2356 | frate = d->frate; | |
| 483 | } | ||
| 484 | |||
| 485 | 3258 | tile=0; //init to 0 here, but set it later. | |
| 486 | |||
| 487 | 3258 | scripttile = -1; | |
| 488 | 3258 | scriptflip = -1; | |
| 489 | 3258 | do_animation = true; | |
| 490 | 3258 | immortal = false; | |
| 491 | 3258 | noSlide = false; | |
| 492 | 3258 | deathexstate = -1; | |
| 493 | |||
| 494 | 3258 | hashero=false; | |
| 495 | |||
| 496 | // If they forgot the invisibility flag, here's another failsafe: | ||
| 497 |
3/4✓ Branch 0 taken 99 times.
✓ Branch 1 taken 3159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
|
3258 | if(o_tile==0 && family!=eeSPINTILE) |
| 498 | 99 | flags |= guy_invisible; | |
| 499 | |||
| 500 | // step = d->step/100.0; | ||
| 501 | // To preserve the odd step values for Keese & Gleeok heads. -L | ||
| 502 |
5/8✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 448 times.
✓ Branch 5 taken 2810 times.
✓ Branch 6 taken 448 times.
✗ Branch 7 not taken.
|
3258 | if(dstep==62.0) dstep+=0.5; |
| 503 |
5/8✓ Branch 0 taken 2810 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2810 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 2798 times.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
|
2810 | else if(dstep==89) dstep-=1/9; |
| 504 | |||
| 505 |
5/10✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3258 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3258 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3258 times.
✗ Branch 9 not taken.
|
3258 | step = zslongToFix(dstep*100); |
| 506 | |||
| 507 | |||
| 508 | 3258 | item_set = d->item_set; | |
| 509 | 3258 | grumble = d->grumble; | |
| 510 | |||
| 511 |
2/2✓ Branch 0 taken 2582 times.
✓ Branch 1 taken 676 times.
|
3258 | if(frate == 0) |
| 512 | 676 | frate = 256; | |
| 513 | |||
| 514 | 3258 | leader = itemguy = dying = scored = false; | |
| 515 | 3258 | canfreeze = count_enemy = true; | |
| 516 | 3258 | mainguy = !(flags & guy_doesntcount); | |
| 517 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | dir = zc_oldrand()&3; |
| 518 | |||
| 519 | //2.6 Enemy Editor Hit and TIle Sizes | ||
| 520 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
3258 | if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 521 | //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z | ||
| 522 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 523 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
3258 | if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 524 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3258 | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz; |
| 525 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3258 | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz; |
| 526 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3258 | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz; |
| 527 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 528 |
1/2✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
|
3258 | if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 529 | // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs; | ||
| 530 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3258 | if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 531 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
|
3258 | if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 532 | { | ||
| 533 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 534 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 535 | ✗ | } | |
| 536 | |||
| 537 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3258 | if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 538 | |||
| 539 | 3258 | SIZEflags = d->SIZEflags; | |
| 540 | |||
| 541 |
7/10✓ Branch 0 taken 3256 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3256 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
|
3258 | if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU)) |
| 542 | ✗ | wpn = 0; | |
| 543 | |||
| 544 | //tile should never be 0 after init --Z (failsafe) | ||
| 545 |
4/6✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1278 times.
✓ Branch 5 taken 1980 times.
|
3258 | if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;} |
| 546 | |||
| 547 | //Moveflags; for gravity and pit interaction | ||
| 548 | 3258 | moveflags = d->moveflags; | |
| 549 |
3/4✓ Branch 0 taken 3258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2752 times.
✓ Branch 3 taken 506 times.
|
3258 | if(!can_pitfall(false)) |
| 550 | { | ||
| 551 | //Some enemies must not interact with pits. Force their flags, for sanity's sake. | ||
| 552 | 506 | moveflags &= ~FLAG_CAN_PITFALL; | |
| 553 | 506 | moveflags &= ~FLAG_CAN_WATERDROWN; | |
| 554 | 506 | } | |
| 555 | |||
| 556 | 3258 | shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false; | |
| 557 | 3258 | } | |
| 558 | |||
| 559 | ✗ | int32_t enemy::getScriptUID() { return script_UID; } | |
| 560 | ✗ | void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; } | |
| 561 | 2925 | enemy::~enemy() | |
| 562 | 2925 | { | |
| 563 |
2/4✓ Branch 0 taken 2925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2925 times.
✗ Branch 3 not taken.
|
2925 | FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID()); |
| 564 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2925 times.
|
2925 | if(hashero) |
| 565 | { | ||
| 566 | ✗ | Hero.setEaten(0); | |
| 567 | ✗ | hashero=false; | |
| 568 | ✗ | } | |
| 569 | 2925 | } | |
| 570 | |||
| 571 | |||
| 572 | ✗ | bool enemy::is_move_paused() | |
| 573 | { | ||
| 574 | ✗ | return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk); | |
| 575 | } | ||
| 576 | |||
| 577 | ✗ | bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb) | |
| 578 | { | ||
| 579 | ✗ | int32_t yg = (special==spw_floater)?8:0; | |
| 580 | ✗ | int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0; | |
| 581 | //Z_eventlog("Checking x,y %d,%d\n",dx,dy); | ||
| 582 | ✗ | if(input_x == -1000) | |
| 583 | ✗ | input_x = dx; | |
| 584 | ✗ | if(input_y == -1000) | |
| 585 | ✗ | input_y = dy; | |
| 586 | |||
| 587 | ✗ | if(!(moveflags & FLAG_IGNORE_SCREENEDGE) | |
| 588 | ✗ | && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0)) | |
| 589 | ✗ | || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb)))) | |
| 590 | ✗ | return true; | |
| 591 | |||
| 592 | ✗ | if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back | |
| 593 | { | ||
| 594 | ✗ | if(ispitfall(dx,dy)) | |
| 595 | ✗ | return true; | |
| 596 | ✗ | } | |
| 597 | |||
| 598 | ✗ | bool flying = false; | |
| 599 | ✗ | bool cansolid = false; | |
| 600 | ✗ | if(moveflags & FLAG_IGNORE_SOLIDITY) | |
| 601 | ✗ | cansolid = true; | |
| 602 | ✗ | switch(special) | |
| 603 | { | ||
| 604 | case spw_clipbottomright: | ||
| 605 | ✗ | if(dy>=128 || dx>=208) return true; | |
| 606 | ✗ | break; | |
| 607 | case spw_clipright: | ||
| 608 | ✗ | break; //if(input_x>=208) return true; break; | |
| 609 | |||
| 610 | case spw_wizzrobe: // fall through | ||
| 611 | case spw_floater: // Special case for fliers and wizzrobes - hack! | ||
| 612 | { | ||
| 613 | ✗ | if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE)) | |
| 614 | { | ||
| 615 | ✗ | if(dy < 32-yg || dy >= 144) return true; | |
| 616 | ✗ | if(dx < 32 || dx >= 224) return true; | |
| 617 | ✗ | } | |
| 618 | ✗ | if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb)) | |
| 619 | ✗ | return true; | |
| 620 | ✗ | cansolid = true; | |
| 621 | ✗ | flying = true; | |
| 622 | } | ||
| 623 | ✗ | } | |
| 624 | |||
| 625 | ✗ | dx &= ~7; | |
| 626 | ✗ | dy &= ~7; | |
| 627 | |||
| 628 | ✗ | if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true; | |
| 629 | |||
| 630 | ✗ | if (dx < 0 || dx > 255 || dy < 0 || dy > 175) | |
| 631 | ✗ | return !(moveflags & FLAG_IGNORE_SCREENEDGE); | |
| 632 | //_walkflag code | ||
| 633 | mapscr *s1, *s2; | ||
| 634 | ✗ | s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL; | |
| 635 | ✗ | s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL; | |
| 636 | |||
| 637 | ✗ | int32_t cpos=(dx>>4)+(dy&0xF0); | |
| 638 | ✗ | int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos]; | |
| 639 | ✗ | newcombo const& c = combobuf[ci]; | |
| 640 | ✗ | newcombo const& c1 = combobuf[ci1]; | |
| 641 | ✗ | newcombo const& c2 = combobuf[ci2]; | |
| 642 | |||
| 643 | ✗ | int32_t b=1; | |
| 644 | ✗ | if(dx&8) b<<=2; | |
| 645 | ✗ | if(dy&8) b<<=1; | |
| 646 | |||
| 647 | #define iwtr(cmb, x, y, shallow) \ | ||
| 648 | (shallow \ | ||
| 649 | ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \ | ||
| 650 | && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \ | ||
| 651 | : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false)) | ||
| 652 | ✗ | bool wtr = iwtr(ci, dx, dy, false); | |
| 653 | ✗ | bool shwtr = iwtr(ci, dx, dy, true); | |
| 654 | ✗ | bool pit = ispitfall(dx,dy); | |
| 655 | |||
| 656 | ✗ | bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb); | |
| 657 | ✗ | bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb); | |
| 658 | ✗ | bool needwtr = (moveflags & FLAG_ONLY_WATERWALK); | |
| 659 | ✗ | bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK); | |
| 660 | ✗ | bool needpit = (moveflags & FLAG_ONLY_PITWALK); | |
| 661 | |||
| 662 | ✗ | if(!cansolid) | |
| 663 | { | ||
| 664 | ✗ | int32_t cwalkflag = c.walk & 0xF; | |
| 665 | ✗ | if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0; | |
| 666 | ✗ | if (s1) | |
| 667 | { | ||
| 668 | ✗ | if (c1.type == cBRIDGE) | |
| 669 | { | ||
| 670 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 671 | { | ||
| 672 | ✗ | int efflag = (c1.walk & 0xF0)>>4; | |
| 673 | ✗ | int newsolid = (c1.walk & 0xF); | |
| 674 | ✗ | cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag); | |
| 675 | ✗ | } | |
| 676 | ✗ | else cwalkflag &= c1.walk; | |
| 677 | ✗ | } | |
| 678 | ✗ | else cwalkflag |= c1.walk & 0xF; | |
| 679 | ✗ | } | |
| 680 | ✗ | if (s2) | |
| 681 | { | ||
| 682 | ✗ | if (c2.type == cBRIDGE) | |
| 683 | { | ||
| 684 | ✗ | if (!get_qr(qr_OLD_BRIDGE_COMBOS)) | |
| 685 | { | ||
| 686 | ✗ | int efflag = (c2.walk & 0xF0)>>4; | |
| 687 | ✗ | int newsolid = (c2.walk & 0xF); | |
| 688 | ✗ | cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag); | |
| 689 | ✗ | } | |
| 690 | ✗ | else cwalkflag &= c2.walk; | |
| 691 | ✗ | } | |
| 692 | ✗ | else cwalkflag |= c2.walk & 0xF; | |
| 693 | ✗ | } | |
| 694 | ✗ | if(cwalkflag & b) | |
| 695 | ✗ | return true; | |
| 696 | ✗ | } | |
| 697 | ✗ | if(needwtr || needshwtr || needpit) | |
| 698 | { | ||
| 699 | ✗ | bool ret = true; | |
| 700 | ✗ | if (needwtr && wtr) ret = false; | |
| 701 | ✗ | else if (needshwtr && shwtr) ret = false; | |
| 702 | ✗ | else if (needpit && pit) ret = false; | |
| 703 | ✗ | return ret; | |
| 704 | } | ||
| 705 | ✗ | else if(wtr && !canwtr) | |
| 706 | ✗ | return true; | |
| 707 | ✗ | else if(pit && !canpit) | |
| 708 | ✗ | return true; | |
| 709 | |||
| 710 | ✗ | return false; | |
| 711 | ✗ | } | |
| 712 | |||
| 713 | ✗ | bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv) | |
| 714 | { | ||
| 715 | ✗ | if(!(dx || dy)) return true; | |
| 716 | ✗ | zfix bx = x+hxofs, by = y+hyofs; //left/top | |
| 717 | ✗ | zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom | |
| 718 | ✗ | if(!ign_sv && dy < 0) //check gravity | |
| 719 | { | ||
| 720 | ✗ | if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity()) | |
| 721 | ✗ | return false; | |
| 722 | ✗ | } | |
| 723 | |||
| 724 | ✗ | bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater)); | |
| 725 | |||
| 726 | ✗ | if(dx && !dy) | |
| 727 | { | ||
| 728 | ✗ | if(dx < 0) | |
| 729 | { | ||
| 730 | ✗ | special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special; | |
| 731 | ✗ | int mx = (bx+dx).getFloor(); | |
| 732 | ✗ | for(zfix ty = 0; by+ty < ry; ty += 8) | |
| 733 | { | ||
| 734 | ✗ | if(scr_walkflag(mx, by+ty, special, left, mx, by, kb)) | |
| 735 | ✗ | return false; | |
| 736 | ✗ | } | |
| 737 | ✗ | if(scr_walkflag(mx, ry, special, left, mx, by, kb)) | |
| 738 | ✗ | return false; | |
| 739 | ✗ | if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this)) | |
| 740 | ✗ | return false; | |
| 741 | ✗ | } | |
| 742 | else | ||
| 743 | { | ||
| 744 | ✗ | int mx = (rx+dx).getCeil(); | |
| 745 | ✗ | int lx = mx-hit_width+1; | |
| 746 | ✗ | for(zfix ty = 0; by+ty < ry; ty += 8) | |
| 747 | { | ||
| 748 | ✗ | if(scr_walkflag(mx, by+ty, special, right, lx, by, kb)) | |
| 749 | ✗ | return false; | |
| 750 | ✗ | } | |
| 751 | ✗ | if(scr_walkflag(mx, ry, special, right, lx, by, kb)) | |
| 752 | ✗ | return false; | |
| 753 | ✗ | if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this)) | |
| 754 | ✗ | return false; | |
| 755 | } | ||
| 756 | ✗ | } | |
| 757 | ✗ | else if(dy && !dx) | |
| 758 | { | ||
| 759 | ✗ | if(dy < 0) | |
| 760 | { | ||
| 761 | ✗ | special = (special==spw_clipbottomright)?spw_none:special; | |
| 762 | ✗ | int my = (by+dy).getFloor(); | |
| 763 | ✗ | for(zfix tx = 0; bx+tx < rx; tx += 8) | |
| 764 | { | ||
| 765 | ✗ | if(scr_walkflag(bx+tx, my, special, up, bx, my, kb)) | |
| 766 | ✗ | return false; | |
| 767 | ✗ | } | |
| 768 | ✗ | if(scr_walkflag(rx, my, special, up, bx, my, kb)) | |
| 769 | ✗ | return false; | |
| 770 | ✗ | if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this)) | |
| 771 | ✗ | return false; | |
| 772 | ✗ | } | |
| 773 | else | ||
| 774 | { | ||
| 775 | ✗ | int my = (ry+dy).getCeil(); | |
| 776 | ✗ | int ly = my-hit_height+1; | |
| 777 | ✗ | for(zfix tx = 0; bx+tx < rx; tx += 8) | |
| 778 | { | ||
| 779 | ✗ | if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb)) | |
| 780 | ✗ | return false; | |
| 781 | ✗ | } | |
| 782 | ✗ | if(scr_walkflag(rx, my, special, down, bx, ly, kb)) | |
| 783 | ✗ | return false; | |
| 784 | ✗ | if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this)) | |
| 785 | ✗ | return false; | |
| 786 | } | ||
| 787 | ✗ | } | |
| 788 | else //! Untested, and currently unused. | ||
| 789 | { | ||
| 790 | ✗ | return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv); | |
| 791 | } | ||
| 792 | ✗ | return true; | |
| 793 | ✗ | } | |
| 794 | |||
| 795 | ✗ | bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb) | |
| 796 | { | ||
| 797 | ✗ | zfix bx = dx+hxofs, by = dy+hyofs; //left/top | |
| 798 | ✗ | zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom | |
| 799 | |||
| 800 | ✗ | bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater)); | |
| 801 | |||
| 802 | ✗ | if(nosolid && collide_object(bx,by,hit_width,hit_height,this)) | |
| 803 | ✗ | return false; | |
| 804 | ✗ | for(zfix ty = 0; by+ty < ry; ty += 8) | |
| 805 | { | ||
| 806 | ✗ | for(zfix tx = 0; bx+tx < rx; tx += 8) | |
| 807 | { | ||
| 808 | ✗ | if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb)) | |
| 809 | ✗ | return false; | |
| 810 | ✗ | } | |
| 811 | ✗ | if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb)) | |
| 812 | ✗ | return false; | |
| 813 | ✗ | } | |
| 814 | ✗ | for(zfix tx = 0; bx+tx < rx; tx += 8) | |
| 815 | { | ||
| 816 | ✗ | if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb)) | |
| 817 | ✗ | return false; | |
| 818 | ✗ | } | |
| 819 | ✗ | if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb)) | |
| 820 | ✗ | return false; | |
| 821 | ✗ | return true; | |
| 822 | ✗ | } | |
| 823 | |||
| 824 | ✗ | bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei) | |
| 825 | { | ||
| 826 | ✗ | auto oxsz = hit_width, oysz = hit_height; | |
| 827 | ✗ | if(nwid > -1) hit_width = nwid; | |
| 828 | ✗ | if(nhei > -1) hit_height = nhei; | |
| 829 | ✗ | bool ret = scr_canplace(dx,dy,special,kb); | |
| 830 | ✗ | hit_width = oxsz; hit_height = oysz; | |
| 831 | ✗ | return ret; | |
| 832 | } | ||
| 833 | |||
| 834 | ✗ | bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret) | |
| 835 | { | ||
| 836 | ✗ | bool ret = true; | |
| 837 | ✗ | if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity()) | |
| 838 | ✗ | dy = 0; | |
| 839 | ✗ | const int scl = 2; | |
| 840 | ✗ | while(abs(dx) > scl || abs(dy) > scl) | |
| 841 | { | ||
| 842 | ✗ | if(abs(dx) > abs(dy)) | |
| 843 | { | ||
| 844 | ✗ | int32_t tdx = dx.sign() * scl; | |
| 845 | ✗ | if(movexy(tdx, 0, special, kb, ign_sv, earlyret)) | |
| 846 | ✗ | dx -= tdx; | |
| 847 | else | ||
| 848 | { | ||
| 849 | ✗ | if(earlyret) return false; | |
| 850 | ✗ | dx = tdx; | |
| 851 | ✗ | ret = false; | |
| 852 | } | ||
| 853 | ✗ | } | |
| 854 | else | ||
| 855 | { | ||
| 856 | ✗ | int32_t tdy = dy.sign() * scl; | |
| 857 | ✗ | if(movexy(0, tdy, special, kb, ign_sv, earlyret)) | |
| 858 | ✗ | dy -= tdy; | |
| 859 | else | ||
| 860 | { | ||
| 861 | ✗ | if(earlyret) return false; | |
| 862 | ✗ | dy = tdy; | |
| 863 | ✗ | ret = false; | |
| 864 | } | ||
| 865 | } | ||
| 866 | } | ||
| 867 | |||
| 868 | ✗ | if(dx) | |
| 869 | { | ||
| 870 | ✗ | if(scr_canmove(dx, 0, special, kb, ign_sv)) | |
| 871 | ✗ | x += dx; | |
| 872 | else | ||
| 873 | { | ||
| 874 | ✗ | if(earlyret) return false; | |
| 875 | ✗ | ret = false; | |
| 876 | ✗ | int xsign = dx.sign(); | |
| 877 | ✗ | while(scr_canmove(xsign, 0, special, kb, ign_sv)) | |
| 878 | { | ||
| 879 | ✗ | x += xsign; | |
| 880 | ✗ | dx -= xsign; | |
| 881 | } | ||
| 882 | ✗ | if(dx) | |
| 883 | { | ||
| 884 | ✗ | dx.doDecBound(0,-9999, 0,9999); | |
| 885 | ✗ | dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){ | |
| 886 | ✗ | if(scr_canmove(val, 0, special, kb, ign_sv)) | |
| 887 | { | ||
| 888 | ✗ | retval = val; | |
| 889 | ✗ | return BSEARCH_CONTINUE_AWAY0; | |
| 890 | } | ||
| 891 | ✗ | else return BSEARCH_CONTINUE_TOWARD0; | |
| 892 | ✗ | }); | |
| 893 | ✗ | x += dx; | |
| 894 | ✗ | } | |
| 895 | } | ||
| 896 | ✗ | } | |
| 897 | ✗ | if(dy) | |
| 898 | { | ||
| 899 | ✗ | if(scr_canmove(0, dy, special, kb, ign_sv)) | |
| 900 | ✗ | y += dy; | |
| 901 | else | ||
| 902 | { | ||
| 903 | ✗ | if(earlyret) return false; | |
| 904 | ✗ | ret = false; | |
| 905 | ✗ | int ysign = dy.sign(); | |
| 906 | ✗ | while(scr_canmove(0, ysign, special, kb, ign_sv)) | |
| 907 | { | ||
| 908 | ✗ | y += ysign; | |
| 909 | ✗ | dy -= ysign; | |
| 910 | } | ||
| 911 | ✗ | if(dy) | |
| 912 | { | ||
| 913 | ✗ | dy.doDecBound(0,-9999, 0,9999); | |
| 914 | ✗ | dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){ | |
| 915 | ✗ | if(scr_canmove(0, val, special, kb, ign_sv)) | |
| 916 | { | ||
| 917 | ✗ | retval = val; | |
| 918 | ✗ | return BSEARCH_CONTINUE_AWAY0; | |
| 919 | } | ||
| 920 | ✗ | else return BSEARCH_CONTINUE_TOWARD0; | |
| 921 | ✗ | }); | |
| 922 | ✗ | y += dy; | |
| 923 | ✗ | } | |
| 924 | } | ||
| 925 | ✗ | } | |
| 926 | ✗ | return ret; | |
| 927 | ✗ | } | |
| 928 | |||
| 929 | ✗ | bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret) | |
| 930 | { | ||
| 931 | ✗ | static const zfix diagrate = zslongToFix(7071); | |
| 932 | ✗ | switch(NORMAL_DIR(dir)) | |
| 933 | { | ||
| 934 | case up: | ||
| 935 | ✗ | return movexy(0, -px, special, kb, false, earlyret); | |
| 936 | case down: | ||
| 937 | ✗ | return movexy(0, px, special, kb, false, earlyret); | |
| 938 | case left: | ||
| 939 | ✗ | return movexy(-px, 0, special, kb, false, earlyret); | |
| 940 | case right: | ||
| 941 | ✗ | return movexy(px, 0, special, kb, false, earlyret); | |
| 942 | case r_up: | ||
| 943 | ✗ | return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret); | |
| 944 | case r_down: | ||
| 945 | ✗ | return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret); | |
| 946 | case l_up: | ||
| 947 | ✗ | return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret); | |
| 948 | case l_down: | ||
| 949 | ✗ | return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret); | |
| 950 | } | ||
| 951 | ✗ | return false; | |
| 952 | ✗ | } | |
| 953 | |||
| 954 | ✗ | bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret) | |
| 955 | { | ||
| 956 | ✗ | double v = degrees.getFloat() * PI / 180.0; | |
| 957 | ✗ | zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px; | |
| 958 | ✗ | return movexy(dx, dy, special, kb, false, earlyret); | |
| 959 | } | ||
| 960 | |||
| 961 | ✗ | bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb) | |
| 962 | { | ||
| 963 | ✗ | zfix tx = x, ty = y; | |
| 964 | ✗ | bool ret = movexy(dx, dy, special, kb, false, true); | |
| 965 | ✗ | x = tx; | |
| 966 | ✗ | y = ty; | |
| 967 | ✗ | return ret; | |
| 968 | } | ||
| 969 | ✗ | bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb) | |
| 970 | { | ||
| 971 | ✗ | zfix tx = x, ty = y; | |
| 972 | ✗ | bool ret = moveDir(dir, px, special, kb, true); | |
| 973 | ✗ | x = tx; | |
| 974 | ✗ | y = ty; | |
| 975 | ✗ | return ret; | |
| 976 | } | ||
| 977 | ✗ | bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb) | |
| 978 | { | ||
| 979 | ✗ | zfix tx = x, ty = y; | |
| 980 | ✗ | bool ret = moveAtAngle(degrees, px, special, kb, true); | |
| 981 | ✗ | x = tx; | |
| 982 | ✗ | y = ty; | |
| 983 | ✗ | return ret; | |
| 984 | } | ||
| 985 | |||
| 986 | // Handle pitfalls | ||
| 987 | 834426 | bool enemy::do_falling(int32_t index) | |
| 988 | { | ||
| 989 |
2/2✓ Branch 0 taken 834284 times.
✓ Branch 1 taken 142 times.
|
834426 | if(fallclk > 0) |
| 990 | { | ||
| 991 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
142 | if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt())); |
| 992 |
2/2✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
|
142 | if(!--fallclk) |
| 993 | { | ||
| 994 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if(immortal) //Keep alive forever |
| 995 | ✗ | ++fallclk; //force another frame of falling.... forever. | |
| 996 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | else if(dying) //Give 1 frame for script revival |
| 997 | { | ||
| 998 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(flags&guy_neverret) |
| 999 | ✗ | never_return(index); | |
| 1000 | |||
| 1001 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(leader) |
| 1002 | ✗ | kill_em_all(); | |
| 1003 | |||
| 1004 | //leave_item(); //Don't drop items in pits! | ||
| 1005 | 2 | stop_bgsfx(index); | |
| 1006 | 2 | return true; | |
| 1007 | } | ||
| 1008 | else | ||
| 1009 | { | ||
| 1010 | 2 | try_death(true); //Force death | |
| 1011 | 2 | ++fallclk; //force another frame of falling | |
| 1012 | } | ||
| 1013 | 2 | } | |
| 1014 | |||
| 1015 | 140 | wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]]; | |
| 1016 | 140 | cs = spr.csets & 0xF; | |
| 1017 |
1/2✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
|
140 | int32_t fr = spr.frames ? spr.frames : 1; |
| 1018 |
1/2✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
|
140 | int32_t spd = spr.speed ? spr.speed : 1; |
| 1019 | 140 | int32_t animclk = (PITFALL_FALL_FRAMES-fallclk); | |
| 1020 |
2/2✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
|
140 | tile = spr.tile + zc_min(animclk / spd, fr-1); |
| 1021 | 140 | } | |
| 1022 | 834424 | return false; | |
| 1023 | 834426 | } | |
| 1024 | |||
| 1025 | // Handle drowning in water | ||
| 1026 | 834284 | bool enemy::do_drowning(int32_t index) | |
| 1027 | { | ||
| 1028 |
1/2✓ Branch 0 taken 834284 times.
✗ Branch 1 not taken.
|
834284 | if(drownclk > 0) |
| 1029 | { | ||
| 1030 | //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt())); | ||
| 1031 | //!TODO: Drown SFX | ||
| 1032 | ✗ | if(!--drownclk) | |
| 1033 | { | ||
| 1034 | ✗ | if(immortal) //Keep alive forever | |
| 1035 | ✗ | ++drownclk; //force another frame of falling.... forever. | |
| 1036 | ✗ | else if(dying) //Give 1 frame for script revival | |
| 1037 | { | ||
| 1038 | ✗ | if(flags&guy_neverret) | |
| 1039 | ✗ | never_return(index); | |
| 1040 | |||
| 1041 | ✗ | if(leader) | |
| 1042 | ✗ | kill_em_all(); | |
| 1043 | |||
| 1044 | //leave_item(); //Don't drop items in pits! | ||
| 1045 | ✗ | stop_bgsfx(index); | |
| 1046 | ✗ | return true; | |
| 1047 | } | ||
| 1048 | else | ||
| 1049 | { | ||
| 1050 | ✗ | try_death(true); //Force death | |
| 1051 | ✗ | ++drownclk; //force another frame of falling | |
| 1052 | } | ||
| 1053 | ✗ | } | |
| 1054 | |||
| 1055 | ✗ | if (drownCombo && combobuf[drownCombo].usrflags&cflag1) | |
| 1056 | { | ||
| 1057 | ✗ | wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]]; | |
| 1058 | ✗ | cs = spr.csets & 0xF; | |
| 1059 | ✗ | int32_t fr = spr.frames ? spr.frames : 1; | |
| 1060 | ✗ | int32_t spd = spr.speed ? spr.speed : 1; | |
| 1061 | ✗ | int32_t animclk = (WATER_DROWN_FRAMES-drownclk); | |
| 1062 | ✗ | tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1); | |
| 1063 | ✗ | } | |
| 1064 | else | ||
| 1065 | { | ||
| 1066 | ✗ | wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]]; | |
| 1067 | ✗ | cs = spr.csets & 0xF; | |
| 1068 | ✗ | int32_t fr = spr.frames ? spr.frames : 1; | |
| 1069 | ✗ | int32_t spd = spr.speed ? spr.speed : 1; | |
| 1070 | ✗ | int32_t animclk = (WATER_DROWN_FRAMES-drownclk); | |
| 1071 | ✗ | tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1); | |
| 1072 | } | ||
| 1073 | ✗ | } | |
| 1074 | 834284 | return false; | |
| 1075 | 834284 | } | |
| 1076 | |||
| 1077 | // Supplemental animation code that all derived classes should call | ||
| 1078 | // as a return value for animate(). | ||
| 1079 | // Handles the death animation and returns true when enemy is finished. | ||
| 1080 | 856002 | bool enemy::Dead(int32_t index) | |
| 1081 | { | ||
| 1082 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 856002 times.
|
856002 | if(immortal) |
| 1083 | { | ||
| 1084 | ✗ | dying = false; | |
| 1085 | ✗ | return false; | |
| 1086 | } | ||
| 1087 |
2/2✓ Branch 0 taken 23002 times.
✓ Branch 1 taken 833000 times.
|
856002 | if(dying) |
| 1088 | { | ||
| 1089 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 23002 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
23002 | if(deathexstate > -1 && deathexstate < 32) |
| 1090 | { | ||
| 1091 | ✗ | setxmapflag(1<<deathexstate); | |
| 1092 | ✗ | deathexstate = -1; | |
| 1093 | ✗ | } | |
| 1094 | 23002 | --clk2; | |
| 1095 | |||
| 1096 |
4/4✓ Branch 0 taken 20808 times.
✓ Branch 1 taken 2194 times.
✓ Branch 2 taken 1090 times.
✓ Branch 3 taken 16 times.
|
23002 | if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12) |
| 1097 |
2/2✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 19702 times.
|
20808 | && hp>-1000) // not killed by ringleader |
| 1098 | 1090 | death_sfx(); | |
| 1099 | |||
| 1100 |
2/2✓ Branch 0 taken 21813 times.
✓ Branch 1 taken 1189 times.
|
23002 | if(clk2==0) |
| 1101 | { | ||
| 1102 |
2/2✓ Branch 0 taken 1168 times.
✓ Branch 1 taken 21 times.
|
1189 | if(flags&guy_neverret) |
| 1103 | 21 | never_return(index); | |
| 1104 | |||
| 1105 |
2/2✓ Branch 0 taken 1186 times.
✓ Branch 1 taken 3 times.
|
1189 | if(leader) |
| 1106 | 3 | kill_em_all(); | |
| 1107 | |||
| 1108 | 1189 | leave_item(); | |
| 1109 | 1189 | } | |
| 1110 | |||
| 1111 | 23002 | stop_bgsfx(index); | |
| 1112 | 23002 | return (clk2==0); | |
| 1113 | } | ||
| 1114 | |||
| 1115 | 833000 | return false; | |
| 1116 | 856002 | } | |
| 1117 | |||
| 1118 | // Basic animation code that all derived classes should call. | ||
| 1119 | // The one with an index is the one that is called by | ||
| 1120 | // the guys sprite list; index is the enemy's index in the list. | ||
| 1121 | 834426 | bool enemy::animate(int32_t index) | |
| 1122 | { | ||
| 1123 |
2/2✓ Branch 0 taken 12866 times.
✓ Branch 1 taken 821560 times.
|
834426 | if(sclk <= 0) hitdir = -1; |
| 1124 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 834426 times.
|
834426 | if(switch_hooked) |
| 1125 | { | ||
| 1126 | ✗ | if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) | |
| 1127 | { | ||
| 1128 | //Run its script | ||
| 1129 | ✗ | if (!didScriptThisFrame) | |
| 1130 | { | ||
| 1131 | ✗ | if (runscript_do_earlyret(run_script(MODE_NORMAL))) | |
| 1132 | { | ||
| 1133 | ✗ | return 0; //Avoid NULLPO if this object deleted itself | |
| 1134 | } | ||
| 1135 | ✗ | } | |
| 1136 | ✗ | } | |
| 1137 | ✗ | return false; | |
| 1138 | } | ||
| 1139 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 834424 times.
|
834426 | if(do_falling(index)) return true; |
| 1140 |
2/2✓ Branch 0 taken 140 times.
✓ Branch 1 taken 834284 times.
|
834424 | else if(fallclk) |
| 1141 | { | ||
| 1142 | //clks | ||
| 1143 |
2/2✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
|
140 | if(hclk>0) |
| 1144 | 60 | --hclk; | |
| 1145 |
1/2✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
|
140 | if(stunclk>0) |
| 1146 | ✗ | --stunclk; | |
| 1147 |
1/2✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
|
140 | if ( frozenclock > 0 ) |
| 1148 | ✗ | --frozenclock; | |
| 1149 |
1/2✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
|
140 | if(hashero) |
| 1150 | { | ||
| 1151 | ✗ | Hero.setX(x); | |
| 1152 | ✗ | Hero.setY(y); | |
| 1153 | ✗ | Hero.fallCombo = fallCombo; | |
| 1154 | ✗ | Hero.fallclk = fallclk; | |
| 1155 | ✗ | hashero = false; //Let Hero go if falling | |
| 1156 | ✗ | } | |
| 1157 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
|
140 | if (!didScriptThisFrame) |
| 1158 | { | ||
| 1159 | 140 | run_script(MODE_NORMAL); | |
| 1160 | 140 | } | |
| 1161 | 140 | return false; | |
| 1162 | } | ||
| 1163 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 834284 times.
|
834284 | if(do_drowning(index)) return true; |
| 1164 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 834284 times.
|
834284 | else if(drownclk) |
| 1165 | { | ||
| 1166 | //clks | ||
| 1167 | ✗ | if(hclk>0) | |
| 1168 | ✗ | --hclk; | |
| 1169 | ✗ | if(stunclk>0) | |
| 1170 | ✗ | --stunclk; | |
| 1171 | ✗ | if ( frozenclock > 0 ) | |
| 1172 | ✗ | --frozenclock; | |
| 1173 | ✗ | if(hashero) | |
| 1174 | { | ||
| 1175 | ✗ | Hero.setX(x); | |
| 1176 | ✗ | Hero.setY(y); | |
| 1177 | ✗ | Hero.drownclk = drownclk; | |
| 1178 | ✗ | hashero = false; //Let Hero go if falling | |
| 1179 | ✗ | } | |
| 1180 | ✗ | if (!didScriptThisFrame) | |
| 1181 | { | ||
| 1182 | ✗ | run_script(MODE_NORMAL); | |
| 1183 | ✗ | } | |
| 1184 | ✗ | return false; | |
| 1185 | } | ||
| 1186 | 834284 | int32_t nx = real_x(x); | |
| 1187 | 834284 | int32_t ny = real_y(y); | |
| 1188 | |||
| 1189 |
4/4✓ Branch 0 taken 621580 times.
✓ Branch 1 taken 212704 times.
✓ Branch 2 taken 117102 times.
✓ Branch 3 taken 504478 times.
|
834284 | if(ox!=nx || oy!=ny) |
| 1190 | { | ||
| 1191 | 329806 | posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2); | |
| 1192 | 329806 | } | |
| 1193 | |||
| 1194 | 834284 | ox = nx; | |
| 1195 | 834284 | oy = ny; | |
| 1196 | |||
| 1197 | // Maybe they fell off the bottom in sideview, or were moved by a script. | ||
| 1198 | |||
| 1199 | //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z | ||
| 1200 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 834284 times.
|
834284 | if ( immortal ) |
| 1201 | { | ||
| 1202 | //skip, as it can go out of bounds, from immortality | ||
| 1203 | ✗ | } | |
| 1204 |
2/6✓ Branch 0 taken 834284 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 834284 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
834284 | else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) ) |
| 1205 | { | ||
| 1206 | //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!) | ||
| 1207 | ✗ | } | |
| 1208 |
5/10✓ Branch 0 taken 834284 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 834284 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 834284 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 834284 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 834284 times.
|
834284 | else if ( (OUTOFBOUNDS) ) |
| 1209 | { | ||
| 1210 | ✗ | hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled | |
| 1211 | ✗ | } | |
| 1212 | //fall down | ||
| 1213 |
6/6✓ Branch 0 taken 381421 times.
✓ Branch 1 taken 452863 times.
✓ Branch 2 taken 446268 times.
✓ Branch 3 taken 388016 times.
✓ Branch 4 taken 30904 times.
✓ Branch 5 taken 415364 times.
|
834284 | if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0) |
| 1214 | { | ||
| 1215 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 415364 times.
|
415364 | if(isSideViewGravity()) |
| 1216 | { | ||
| 1217 | ✗ | if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE)) | |
| 1218 | { | ||
| 1219 | ✗ | if(!isOnSideviewPlatform()) | |
| 1220 | { | ||
| 1221 | ✗ | bool willHitSVPlatform = false; | |
| 1222 | ✗ | int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hit_width:16; | |
| 1223 | ✗ | int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hit_height:16; | |
| 1224 | ✗ | for(int32_t nx = x+4; nx < x+usewid; nx+=16) | |
| 1225 | { | ||
| 1226 | ✗ | if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0))) | |
| 1227 | { | ||
| 1228 | ✗ | willHitSVPlatform = true; | |
| 1229 | ✗ | break; | |
| 1230 | } | ||
| 1231 | ✗ | } | |
| 1232 | ✗ | if(willHitSVPlatform) | |
| 1233 | { | ||
| 1234 | ✗ | y+=fall/100; | |
| 1235 | //y-=int32_t(y)%16; //Fix to top of SV Ladder | ||
| 1236 | ✗ | do_fix(y, 16); //Fix to top of SV Ladder | |
| 1237 | ✗ | fall = 0; | |
| 1238 | ✗ | } | |
| 1239 | else | ||
| 1240 | { | ||
| 1241 | ✗ | y+=fall/100; | |
| 1242 | ✗ | if(fall <= (int32_t)zinit.terminalv) | |
| 1243 | ✗ | fall += (zinit.gravity/100); | |
| 1244 | } | ||
| 1245 | ✗ | } | |
| 1246 | else | ||
| 1247 | { | ||
| 1248 | ✗ | if(fall!=0) // Only fix pos once | |
| 1249 | { | ||
| 1250 | //y-=(int32_t)y%8; // Fix position | ||
| 1251 | ✗ | do_fix(y, 8); //Fix position | |
| 1252 | ✗ | } | |
| 1253 | |||
| 1254 | ✗ | fall = 0; | |
| 1255 | } | ||
| 1256 | ✗ | } | |
| 1257 | else | ||
| 1258 | { | ||
| 1259 | ✗ | if(isOnSideviewPlatform()) | |
| 1260 | ✗ | fall = 0; | |
| 1261 | else | ||
| 1262 | { | ||
| 1263 | ✗ | zfix fall_amnt = fall/100; | |
| 1264 | ✗ | bool hit = false; | |
| 1265 | ✗ | while(fall_amnt >= 1) | |
| 1266 | { | ||
| 1267 | ✗ | --fall_amnt; | |
| 1268 | ✗ | ++y; | |
| 1269 | ✗ | if(isOnSideviewPlatform()) | |
| 1270 | { | ||
| 1271 | ✗ | y = y.getInt(); | |
| 1272 | ✗ | fall_amnt = 0; | |
| 1273 | ✗ | hit = true; | |
| 1274 | ✗ | break; | |
| 1275 | } | ||
| 1276 | } | ||
| 1277 | ✗ | if(fall_amnt > 0) | |
| 1278 | ✗ | y += fall_amnt; | |
| 1279 | ✗ | if(fall_amnt < 0) | |
| 1280 | { | ||
| 1281 | ✗ | if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP))) | |
| 1282 | ✗ | hit = true; | |
| 1283 | ✗ | } | |
| 1284 | ✗ | if(hit) | |
| 1285 | ✗ | fall = 0; | |
| 1286 | ✗ | else if(fall <= (int32_t)zinit.terminalv) | |
| 1287 | ✗ | fall += (zinit.gravity/100); | |
| 1288 | } | ||
| 1289 | } | ||
| 1290 | ✗ | } | |
| 1291 | else | ||
| 1292 | { | ||
| 1293 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 415364 times.
|
415364 | if (!(moveflags & FLAG_NO_FAKE_Z)) |
| 1294 | { | ||
| 1295 |
2/2✓ Branch 0 taken 215473 times.
✓ Branch 1 taken 199891 times.
|
415364 | if(fakefall!=0) |
| 1296 | 199891 | fakez-=(fakefall/100); | |
| 1297 | |||
| 1298 |
2/2✓ Branch 0 taken 199891 times.
✓ Branch 1 taken 215473 times.
|
415364 | if(fakez<0) |
| 1299 | 199891 | fakez = fakefall = 0; | |
| 1300 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 215473 times.
|
215473 | else if(fakefall <= (int32_t)zinit.terminalv) |
| 1301 | 215473 | fakefall += (zinit.gravity/100); | |
| 1302 | |||
| 1303 |
5/6✓ Branch 0 taken 415364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215473 times.
✓ Branch 3 taken 199891 times.
✓ Branch 4 taken 200645 times.
✓ Branch 5 taken 14828 times.
|
415364 | if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0; |
| 1304 | 415364 | } | |
| 1305 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 415364 times.
|
415364 | if (!(moveflags & FLAG_NO_REAL_Z)) |
| 1306 | { | ||
| 1307 |
2/2✓ Branch 0 taken 216101 times.
✓ Branch 1 taken 199263 times.
|
415364 | if(fall!=0) |
| 1308 | 199263 | z-=(fall/100); | |
| 1309 | |||
| 1310 |
2/2✓ Branch 0 taken 199263 times.
✓ Branch 1 taken 216101 times.
|
415364 | if(z<0) |
| 1311 | 199263 | z = fall = 0; | |
| 1312 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 216101 times.
|
216101 | else if(fall <= (int32_t)zinit.terminalv) |
| 1313 | 216101 | fall += (zinit.gravity/100); | |
| 1314 | |||
| 1315 |
6/6✓ Branch 0 taken 415218 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 215955 times.
✓ Branch 3 taken 199263 times.
✓ Branch 4 taken 201127 times.
✓ Branch 5 taken 14828 times.
|
415364 | if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0; |
| 1316 | 415364 | } | |
| 1317 | |||
| 1318 | } | ||
| 1319 | 415364 | } | |
| 1320 |
3/4✓ Branch 0 taken 834284 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 338588 times.
✓ Branch 3 taken 1172872 times.
|
834284 | if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL)) |
| 1321 | { | ||
| 1322 |
8/10✓ Branch 0 taken 391353 times.
✓ Branch 1 taken 781519 times.
✓ Branch 2 taken 391207 times.
✓ Branch 3 taken 146 times.
✓ Branch 4 taken 391207 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 391353 times.
✓ Branch 8 taken 391207 times.
✓ Branch 9 taken 391207 times.
|
1172872 | if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman) |
| 1323 | { | ||
| 1324 | 391207 | fallCombo = check_pits(); | |
| 1325 | 391207 | } | |
| 1326 | 1955286 | } | |
| 1327 |
4/4✓ Branch 0 taken 834284 times.
✓ Branch 1 taken 116052 times.
✓ Branch 2 taken 833537 times.
✓ Branch 3 taken 747 times.
|
730836 | if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN)) |
| 1328 | { | ||
| 1329 |
7/10✓ Branch 0 taken 254 times.
✓ Branch 1 taken 493 times.
✓ Branch 2 taken 254 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 254 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 254 times.
✓ Branch 8 taken 254 times.
✓ Branch 9 taken 254 times.
|
747 | if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman) |
| 1330 | { | ||
| 1331 | 254 | drownCombo = check_water(); | |
| 1332 | 254 | } | |
| 1333 | 1255 | } | |
| 1334 | |||
| 1335 | 949858 | runKnockback(); //scripted knockback handling | |
| 1336 | |||
| 1337 | // clk is incremented here | ||
| 1338 |
2/2✓ Branch 0 taken 910324 times.
✓ Branch 1 taken 39534 times.
|
949858 | if(++clk >= frate) |
| 1339 | 39534 | clk=0; | |
| 1340 | |||
| 1341 | // hit and death handling | ||
| 1342 |
2/2✓ Branch 0 taken 924317 times.
✓ Branch 1 taken 25541 times.
|
949858 | if(hclk>0) |
| 1343 | 25541 | --hclk; | |
| 1344 | |||
| 1345 |
2/2✓ Branch 0 taken 941787 times.
✓ Branch 1 taken 8071 times.
|
949858 | if(stunclk>0) |
| 1346 | 8071 | --stunclk; | |
| 1347 |
1/2✓ Branch 0 taken 949858 times.
✗ Branch 1 not taken.
|
949858 | if ( frozenclock > 0 ) |
| 1348 | ✗ | --frozenclock; | |
| 1349 | |||
| 1350 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 949858 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
949858 | if(ceiling && z <= 0 && fakez <= 0) |
| 1351 | ✗ | ceiling = false; | |
| 1352 | |||
| 1353 | 949858 | try_death(); | |
| 1354 | |||
| 1355 | 949858 | scored=false; | |
| 1356 | |||
| 1357 | 949858 | ++c_clk; | |
| 1358 | |||
| 1359 | //Run its script | ||
| 1360 |
2/2✓ Branch 0 taken 115919 times.
✓ Branch 1 taken 833939 times.
|
949858 | if (!didScriptThisFrame) |
| 1361 | { | ||
| 1362 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 833939 times.
|
833939 | if (runscript_do_earlyret(run_script(MODE_NORMAL))) |
| 1363 | { | ||
| 1364 | ✗ | return 0; //Avoid NULLPO if this object deleted itself | |
| 1365 | } | ||
| 1366 | 833939 | } | |
| 1367 | |||
| 1368 | // returns true when enemy is defeated | ||
| 1369 | 949858 | return Dead(index); | |
| 1370 | 950000 | } | |
| 1371 | |||
| 1372 | 852843 | bool enemy::setSolid(bool set) | |
| 1373 | { | ||
| 1374 |
1/2✓ Branch 0 taken 852843 times.
✗ Branch 1 not taken.
|
852843 | bool actual = set && !isSubmerged(); |
| 1375 | 852843 | bool ret = solid_object::setSolid(actual); | |
| 1376 | 852843 | solid = set; | |
| 1377 | 852843 | return ret; | |
| 1378 | } | ||
| 1379 | ✗ | void enemy::doContactDamage(int32_t hdir) | |
| 1380 | { | ||
| 1381 | ✗ | Hero.hithero(guys.find(this), hdir); | |
| 1382 | ✗ | } | |
| 1383 | |||
| 1384 | 3278 | void enemy::solid_push(solid_object *obj) | |
| 1385 | { | ||
| 1386 |
1/2✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
|
3278 | if(obj == this) return; //can't push self |
| 1387 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
|
3278 | if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable |
| 1388 | 3278 | zfix dx, dy; | |
| 1389 | 3278 | int32_t hdir = -1; | |
| 1390 | 3278 | solid_push_int(obj,dx,dy,hdir,true); | |
| 1391 | |||
| 1392 |
2/4✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3278 times.
✗ Branch 3 not taken.
|
3278 | if(!dx && !dy) return; |
| 1393 | |||
| 1394 | ✗ | bool t = obj->getTempNonsolid(); | |
| 1395 | ✗ | obj->setTempNonsolid(true); | |
| 1396 | |||
| 1397 | ✗ | int32_t ydir = dy > 0 ? down : up; | |
| 1398 | ✗ | int32_t xdir = dx > 0 ? right : left; | |
| 1399 | |||
| 1400 | ✗ | auto special = isflier(id) ? spw_floater : spw_none; | |
| 1401 | ✗ | if(!movexy(dx,dy,special,true,true)) | |
| 1402 | { | ||
| 1403 | //Crushed? | ||
| 1404 | ✗ | } | |
| 1405 | |||
| 1406 | ✗ | obj->setTempNonsolid(t); | |
| 1407 | 3278 | } | |
| 1408 | 3278 | bool enemy::is_unpushable() const | |
| 1409 | { | ||
| 1410 | 3278 | return isSubmerged(); | |
| 1411 | } | ||
| 1412 | 3278 | bool enemy::sideview_mode() const | |
| 1413 | { | ||
| 1414 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3278 | return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE); |
| 1415 | } | ||
| 1416 | |||
| 1417 | 30 | bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y) | |
| 1418 | { | ||
| 1419 | 30 | int32_t yg = (special==spw_floater)?8:0; | |
| 1420 | 30 | int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0; | |
| 1421 | |||
| 1422 |
7/10✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 30 times.
|
30 | if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb) |
| 1423 | 48 | return true; | |
| 1424 | |||
| 1425 | 30 | bool isInDungeon = isdungeon(); | |
| 1426 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
30 | if(isInDungeon || special==spw_wizzrobe) |
| 1427 | { | ||
| 1428 |
6/8✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 18 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
|
30 | if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144)) |
| 1429 | 12 | return true; | |
| 1430 | |||
| 1431 |
6/8✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
|
18 | if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224)) |
| 1432 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
12 | if(special!=spw_door) // walk in door way |
| 1433 | ✗ | return true; | |
| 1434 | 6 | } | |
| 1435 | |||
| 1436 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
6 | if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func) |
| 1437 | { | ||
| 1438 | ✗ | if(ispitfall(dx,dy) || ispitfall(dx+8,dy) | |
| 1439 | ✗ | || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8)) | |
| 1440 | ✗ | return true; | |
| 1441 | ✗ | } | |
| 1442 | |||
| 1443 |
1/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
6 | switch(special) |
| 1444 | { | ||
| 1445 | case spw_clipbottomright: | ||
| 1446 | ✗ | if(dy>=128 || dx>=208) return true; | |
| 1447 | ✗ | break; | |
| 1448 | case spw_clipright: | ||
| 1449 | ✗ | break; //if(x>=208) return true; break; | |
| 1450 | |||
| 1451 | case spw_wizzrobe: // fall through | ||
| 1452 | case spw_floater: // Special case for fliers and wizzrobes - hack! | ||
| 1453 | { | ||
| 1454 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(isInDungeon) |
| 1455 | { | ||
| 1456 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
|
6 | if(dy < 32-yg || dy >= 144) return true; |
| 1457 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
|
6 | if(dx < 32 || dx >= 224) return true; |
| 1458 | 6 | } | |
| 1459 | 6 | return false; | |
| 1460 | } | ||
| 1461 | } | ||
| 1462 | |||
| 1463 | ✗ | dx&=(special==spw_halfstep)?(~7):(~15); | |
| 1464 | ✗ | dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15); | |
| 1465 | |||
| 1466 | ✗ | if(special==spw_water) | |
| 1467 | ✗ | return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1)); | |
| 1468 | |||
| 1469 | ✗ | return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) || | |
| 1470 | ✗ | groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8); | |
| 1471 | 6 | } | |
| 1472 | |||
| 1473 | 52 | bool enemy::m_walkflag_simple(int32_t dx,int32_t dy) | |
| 1474 | { | ||
| 1475 | 52 | bool kb = false; | |
| 1476 | 52 | int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0; | |
| 1477 | |||
| 1478 |
5/10✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 52 times.
|
52 | if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb) |
| 1479 | ✗ | return true; | |
| 1480 | |||
| 1481 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 36 times.
|
52 | if(isdungeon()) |
| 1482 | { | ||
| 1483 |
2/4✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
|
36 | if((dy<32) || (dy>=144)) |
| 1484 | ✗ | return true; | |
| 1485 | |||
| 1486 |
2/4✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
|
36 | if((dx<32) || (dx>=224)) |
| 1487 | ✗ | return true; | |
| 1488 | 36 | } | |
| 1489 | |||
| 1490 |
2/4✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 52 times.
|
52 | if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back |
| 1491 | { | ||
| 1492 |
2/4✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 52 times.
|
104 | if(ispitfall(dx,dy) || ispitfall(dx+8,dy) |
| 1493 |
2/4✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
|
52 | || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8)) |
| 1494 | ✗ | return true; | |
| 1495 | 52 | } | |
| 1496 | |||
| 1497 |
1/2✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
|
52 | if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY)) |
| 1498 | { | ||
| 1499 |
2/4✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
|
104 | return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) || |
| 1500 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
|
52 | groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb); |
| 1501 | } | ||
| 1502 | else | ||
| 1503 | { | ||
| 1504 | ✗ | return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) || | |
| 1505 | ✗ | _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) || | |
| 1506 | ✗ | groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) || | |
| 1507 | ✗ | groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb); | |
| 1508 | } | ||
| 1509 | 52 | } | |
| 1510 | |||
| 1511 | 749590 | bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb) | |
| 1512 | { | ||
| 1513 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 749590 times.
|
749590 | if(moveflags & FLAG_USE_NEW_MOVEMENT) |
| 1514 | ✗ | return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb); | |
| 1515 | 749590 | int32_t yg = (special==spw_floater)?8:0; | |
| 1516 | 749590 | int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0; | |
| 1517 |
2/2✓ Branch 0 taken 74343 times.
✓ Branch 1 taken 675247 times.
|
749590 | switch(dir) |
| 1518 | { | ||
| 1519 | case l_down: | ||
| 1520 | case r_down: | ||
| 1521 | case down: | ||
| 1522 | case 11: //r_down | ||
| 1523 | case 12: //down | ||
| 1524 | case 13: //l_down | ||
| 1525 | { | ||
| 1526 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 74343 times.
|
74343 | if ( ((unsigned)(id&0xFFF)) < MAXGUYS ) |
| 1527 | { | ||
| 1528 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 74343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
74343 | if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) ) |
| 1529 | { | ||
| 1530 | //Small enemies are treated as 16x16, for the purposes of m_walkflag! | ||
| 1531 | ✗ | dy += zc_max(hit_height-16,0); | |
| 1532 | ✗ | } | |
| 1533 | 74343 | } | |
| 1534 | 74343 | break; | |
| 1535 | } | ||
| 1536 | } | ||
| 1537 |
2/2✓ Branch 0 taken 73586 times.
✓ Branch 1 taken 676004 times.
|
749590 | switch(dir) |
| 1538 | { | ||
| 1539 | case r_up: | ||
| 1540 | case r_down: | ||
| 1541 | case right: | ||
| 1542 | case 9: //r_up | ||
| 1543 | case 10: //right | ||
| 1544 | case 11: //r_down | ||
| 1545 | { | ||
| 1546 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 73586 times.
|
73586 | if ( ((unsigned)(id&0xFFF)) < MAXGUYS ) |
| 1547 | { | ||
| 1548 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 73586 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
73586 | if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) ) |
| 1549 | { | ||
| 1550 | //Small enemies are treated as 16x16, for the purposes of m_walkflag! | ||
| 1551 | ✗ | dx += zc_max(hit_width-16,0); | |
| 1552 | ✗ | } | |
| 1553 | 73586 | } | |
| 1554 | 73586 | break; | |
| 1555 | } | ||
| 1556 | } | ||
| 1557 | //Z_eventlog("Checking x,y %d,%d\n",dx,dy); | ||
| 1558 | |||
| 1559 |
10/10✓ Branch 0 taken 551963 times.
✓ Branch 1 taken 197627 times.
✓ Branch 2 taken 185601 times.
✓ Branch 3 taken 12026 times.
✓ Branch 4 taken 197260 times.
✓ Branch 5 taken 367 times.
✓ Branch 6 taken 197010 times.
✓ Branch 7 taken 250 times.
✓ Branch 8 taken 552596 times.
✓ Branch 9 taken 749606 times.
|
749590 | if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb) |
| 1560 | 1105176 | return true; | |
| 1561 | |||
| 1562 | 749606 | bool isInDungeon = isdungeon(); | |
| 1563 |
4/4✓ Branch 0 taken 52108 times.
✓ Branch 1 taken 697498 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 52007 times.
|
749606 | if(isInDungeon || special==spw_wizzrobe) |
| 1564 | { | ||
| 1565 |
7/8✓ Branch 0 taken 143695 times.
✓ Branch 1 taken 553904 times.
✓ Branch 2 taken 139161 times.
✓ Branch 3 taken 4534 times.
✓ Branch 4 taken 142127 times.
✓ Branch 5 taken 416311 times.
✓ Branch 6 taken 142127 times.
✗ Branch 7 not taken.
|
697599 | if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144)) |
| 1566 | 281288 | return true; | |
| 1567 | |||
| 1568 |
7/8✓ Branch 0 taken 140729 times.
✓ Branch 1 taken 275582 times.
✓ Branch 2 taken 137279 times.
✓ Branch 3 taken 3450 times.
✓ Branch 4 taken 139735 times.
✓ Branch 5 taken 139297 times.
✓ Branch 6 taken 139735 times.
✗ Branch 7 not taken.
|
416311 | if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224)) |
| 1569 |
2/2✓ Branch 0 taken 2453 times.
✓ Branch 1 taken 3 times.
|
277014 | if(special!=spw_door) // walk in door way |
| 1570 | 2453 | return true; | |
| 1571 | 139300 | } | |
| 1572 | |||
| 1573 |
6/6✓ Branch 0 taken 32621 times.
✓ Branch 1 taken 158686 times.
✓ Branch 2 taken 27395 times.
✓ Branch 3 taken 5226 times.
✓ Branch 4 taken 2303 times.
✓ Branch 5 taken 25092 times.
|
191307 | if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back |
| 1574 | { | ||
| 1575 |
3/4✓ Branch 0 taken 30286 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30283 times.
|
60601 | if(ispitfall(dx,dy) || ispitfall(dx+8,dy) |
| 1576 |
3/4✓ Branch 0 taken 30286 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30283 times.
✓ Branch 3 taken 3 times.
|
30286 | || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8)) |
| 1577 | 35 | return true; | |
| 1578 | 30283 | } | |
| 1579 | |||
| 1580 |
3/4✓ Branch 0 taken 157111 times.
✓ Branch 1 taken 34120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
|
191272 | switch(special) |
| 1581 | { | ||
| 1582 | case spw_clipbottomright: | ||
| 1583 | ✗ | if(dy>=128 || dx>=208) return true; | |
| 1584 | ✗ | break; | |
| 1585 | case spw_clipright: | ||
| 1586 | 41 | break; //if(input_x>=208) return true; break; | |
| 1587 | |||
| 1588 | case spw_wizzrobe: // fall through | ||
| 1589 | case spw_floater: // Special case for fliers and wizzrobes - hack! | ||
| 1590 | { | ||
| 1591 |
2/2✓ Branch 0 taken 33118 times.
✓ Branch 1 taken 123993 times.
|
157111 | if(isInDungeon) |
| 1592 | { | ||
| 1593 |
2/4✓ Branch 0 taken 123993 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 123993 times.
|
123993 | if(dy < 32-yg || dy >= 144) return true; |
| 1594 |
3/4✓ Branch 0 taken 123957 times.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 123957 times.
|
123993 | if(dx < 32 || dx >= 224) return true; |
| 1595 | 123957 | } | |
| 1596 | 157075 | return false; | |
| 1597 | } | ||
| 1598 | } | ||
| 1599 | |||
| 1600 | 34161 | dx&=(special==spw_halfstep)?(~7):(~15); | |
| 1601 |
2/2✓ Branch 0 taken 3232 times.
✓ Branch 1 taken 30929 times.
|
34161 | dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15); |
| 1602 | |||
| 1603 |
2/2✓ Branch 0 taken 968 times.
✓ Branch 1 taken 33193 times.
|
34161 | if(special==spw_water) |
| 1604 |
2/2✓ Branch 0 taken 62 times.
✓ Branch 1 taken 906 times.
|
968 | return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1)); |
| 1605 | |||
| 1606 |
2/2✓ Branch 0 taken 32182 times.
✓ Branch 1 taken 1011 times.
|
33193 | if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY)) |
| 1607 | { | ||
| 1608 |
4/4✓ Branch 0 taken 23936 times.
✓ Branch 1 taken 8246 times.
✓ Branch 2 taken 23673 times.
✓ Branch 3 taken 263 times.
|
55855 | return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) || |
| 1609 |
2/2✓ Branch 0 taken 595 times.
✓ Branch 1 taken 23078 times.
|
23673 | groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb); |
| 1610 | } | ||
| 1611 | else | ||
| 1612 | { | ||
| 1613 |
4/4✓ Branch 0 taken 828 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 826 times.
✓ Branch 3 taken 2 times.
|
1837 | return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) || |
| 1614 |
2/4✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 826 times.
✗ Branch 3 not taken.
|
826 | _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) || |
| 1615 |
3/4✓ Branch 0 taken 774 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 774 times.
✗ Branch 3 not taken.
|
826 | groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) || |
| 1616 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
|
774 | groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb); |
| 1617 | } | ||
| 1618 | 197976 | } | |
| 1619 | |||
| 1620 | ✗ | bool enemy::isOnSideviewPlatform() | |
| 1621 | { | ||
| 1622 | ✗ | int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16; | |
| 1623 | ✗ | int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16; | |
| 1624 | ✗ | if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0) | |
| 1625 | ✗ | return false; | |
| 1626 | ✗ | if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map | |
| 1627 | ✗ | if(check_slope(x, y+1, usewid, usehei)) return true; | |
| 1628 | ✗ | for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16) | |
| 1629 | { | ||
| 1630 | ✗ | if(_walkflag(nx,y+usehei,1)) return true; | |
| 1631 | ✗ | if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue; | |
| 1632 | ✗ | if(checkSVLadderPlatform(nx,y+usehei)) return true; | |
| 1633 | ✗ | } | |
| 1634 | ✗ | return false; | |
| 1635 | ✗ | } | |
| 1636 | |||
| 1637 | // Stops playing the given sound only if there are no enemies left to play it | ||
| 1638 | 23077 | void enemy::stop_bgsfx(int32_t index) | |
| 1639 | { | ||
| 1640 |
2/2✓ Branch 0 taken 22733 times.
✓ Branch 1 taken 344 times.
|
23077 | if(bgsfx<=0) |
| 1641 | 22733 | return; | |
| 1642 | |||
| 1643 | // Look for other enemies with the same bgsfx | ||
| 1644 |
2/2✓ Branch 0 taken 649 times.
✓ Branch 1 taken 344 times.
|
993 | for(int32_t i=0; i<guys.Count(); i++) |
| 1645 | { | ||
| 1646 |
3/4✓ Branch 0 taken 305 times.
✓ Branch 1 taken 344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 305 times.
|
649 | if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx) |
| 1647 | ✗ | return; | |
| 1648 | 649 | } | |
| 1649 | |||
| 1650 | 344 | stop_sfx(bgsfx); | |
| 1651 | 23077 | } | |
| 1652 | |||
| 1653 | |||
| 1654 | // to allow for different sfx on defeating enemy | ||
| 1655 | 1177 | void enemy::death_sfx() | |
| 1656 | { | ||
| 1657 |
1/2✓ Branch 0 taken 1177 times.
✗ Branch 1 not taken.
|
1177 | if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x))); |
| 1658 | 1177 | } | |
| 1659 | |||
| 1660 | ✗ | void enemy::move(zfix dx,zfix dy) | |
| 1661 | { | ||
| 1662 | /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 ) | ||
| 1663 | { | ||
| 1664 | switch(family) | ||
| 1665 | { | ||
| 1666 | case eeFIRE: | ||
| 1667 | case eeOTHER: | ||
| 1668 | return; | ||
| 1669 | default: break; | ||
| 1670 | } | ||
| 1671 | if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return; | ||
| 1672 | } | ||
| 1673 | */ | ||
| 1674 | ✗ | if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id))) | |
| 1675 | { | ||
| 1676 | ✗ | x+=dx; | |
| 1677 | ✗ | y+=dy; | |
| 1678 | ✗ | } | |
| 1679 | ✗ | } | |
| 1680 | |||
| 1681 | 457577 | void enemy::move(zfix s) | |
| 1682 | { | ||
| 1683 | /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 ) | ||
| 1684 | { | ||
| 1685 | switch(family) | ||
| 1686 | { | ||
| 1687 | case eeFIRE: | ||
| 1688 | case eeOTHER: | ||
| 1689 | return; | ||
| 1690 | default: break; | ||
| 1691 | } | ||
| 1692 | if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return; | ||
| 1693 | }*/ | ||
| 1694 |
2/10✓ Branch 0 taken 457577 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 457577 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
457577 | if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV))) |
| 1695 | { | ||
| 1696 | 457577 | sprite::move(s); | |
| 1697 | 457577 | } | |
| 1698 | 457577 | } | |
| 1699 | |||
| 1700 | 1193 | void enemy::leave_item() | |
| 1701 | { | ||
| 1702 | 1193 | int32_t drop_item = select_dropitem(item_set, x, y); | |
| 1703 | 1193 | int32_t thedropset = item_set; | |
| 1704 | |||
| 1705 | 1193 | std::vector<int32_t> &ev = FFCore.eventData; | |
| 1706 | 1193 | ev.clear(); | |
| 1707 | 1193 | ev.push_back(getUID()); | |
| 1708 | 1193 | ev.push_back(drop_item*10000); | |
| 1709 | 1193 | ev.push_back(thedropset*10000); | |
| 1710 | |||
| 1711 | 1193 | throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1); | |
| 1712 | 1193 | drop_item = vbound(ev[1] / 10000,-2,255); | |
| 1713 | 1193 | thedropset = ev[2] / 10000; | |
| 1714 | 1193 | ev.clear(); | |
| 1715 |
1/2✓ Branch 0 taken 1193 times.
✗ Branch 1 not taken.
|
1193 | if(drop_item == -2) |
| 1716 | { | ||
| 1717 | ✗ | drop_item = select_dropitem(thedropset,x,y); | |
| 1718 | ✗ | } | |
| 1719 | |||
| 1720 |
5/6✓ Branch 0 taken 400 times.
✓ Branch 1 taken 793 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 379 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
|
1193 | if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir))) |
| 1721 | { | ||
| 1722 | item* itm; | ||
| 1723 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 400 times.
|
400 | if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS)) |
| 1724 | { | ||
| 1725 | ✗ | itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0)); | |
| 1726 | ✗ | } | |
| 1727 | else | ||
| 1728 | { | ||
| 1729 |
8/14✓ Branch 0 taken 1 times.
✓ Branch 1 taken 399 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
|
400 | if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0)); |
| 1730 |
4/8✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 399 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 399 times.
✗ Branch 7 not taken.
|
399 | else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0)); |
| 1731 | } | ||
| 1732 | 400 | itm->from_dropset = thedropset; | |
| 1733 | 400 | items.add(itm); | |
| 1734 | |||
| 1735 | 400 | ev.push_back(getUID()); | |
| 1736 | 400 | ev.push_back(itm->getUID()); | |
| 1737 | |||
| 1738 | 400 | throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2); | |
| 1739 | 400 | ev.clear(); | |
| 1740 | 400 | } | |
| 1741 | 1193 | } | |
| 1742 | |||
| 1743 | // auomatically kill off enemy (for rooms with ringleaders) | ||
| 1744 | 21 | void enemy::kickbucket() | |
| 1745 | { | ||
| 1746 |
1/2✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
|
21 | if(!superman) |
| 1747 | 21 | hp=-1000; // don't call death_sfx() | |
| 1748 | 21 | } | |
| 1749 | |||
| 1750 | 3278 | bool enemy::isSubmerged() const | |
| 1751 | { | ||
| 1752 | 3278 | return submerged; | |
| 1753 | //!TODO SOLIDPUSH more things like teleporting wizzrobes | ||
| 1754 | } | ||
| 1755 | |||
| 1756 | ✗ | void enemy::FireBreath(bool seekhero) | |
| 1757 | { | ||
| 1758 | ✗ | if(wpn==wNone) | |
| 1759 | ✗ | return; | |
| 1760 | |||
| 1761 | ✗ | if(wpn==ewFireTrail) | |
| 1762 | { | ||
| 1763 | ✗ | dmisc1 = e1tEACHTILE; | |
| 1764 | ✗ | FireWeapon(); | |
| 1765 | ✗ | return; | |
| 1766 | } | ||
| 1767 | |||
| 1768 | ✗ | float fire_angle=0.0; | |
| 1769 | ✗ | int32_t wx=0, wy=0, wdir=dir; | |
| 1770 | |||
| 1771 | ✗ | if(!seekhero) | |
| 1772 | { | ||
| 1773 | ✗ | switch(dir) | |
| 1774 | { | ||
| 1775 | case down: | ||
| 1776 | ✗ | fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40; | |
| 1777 | ✗ | wx=x; | |
| 1778 | ✗ | wy=y+8; | |
| 1779 | ✗ | break; | |
| 1780 | |||
| 1781 | case -1: | ||
| 1782 | case up: | ||
| 1783 | ✗ | fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40; | |
| 1784 | ✗ | wx=x; | |
| 1785 | ✗ | wy=y-8; | |
| 1786 | ✗ | break; | |
| 1787 | |||
| 1788 | case left: | ||
| 1789 | ✗ | fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40; | |
| 1790 | ✗ | wx=x-8; | |
| 1791 | ✗ | wy=y; | |
| 1792 | ✗ | break; | |
| 1793 | |||
| 1794 | case right: | ||
| 1795 | ✗ | fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40; | |
| 1796 | ✗ | wx=x+8; | |
| 1797 | ✗ | wy=y; | |
| 1798 | ✗ | break; | |
| 1799 | } | ||
| 1800 | |||
| 1801 | ✗ | if(wpn==ewFlame || wpn==ewFlame2) | |
| 1802 | { | ||
| 1803 | ✗ | if(fire_angle==-PI || fire_angle==PI) wdir=left; | |
| 1804 | ✗ | else if(fire_angle==-PI/2) wdir=up; | |
| 1805 | ✗ | else if(fire_angle==PI/2) wdir=down; | |
| 1806 | ✗ | else if(fire_angle==0) wdir=right; | |
| 1807 | ✗ | else if(fire_angle<-PI/2) wdir=l_up; | |
| 1808 | ✗ | else if(fire_angle<0) wdir=r_up; | |
| 1809 | ✗ | else if(fire_angle<(PI/2)) wdir=r_down; | |
| 1810 | ✗ | else if(fire_angle<PI) wdir=l_down; | |
| 1811 | ✗ | } | |
| 1812 | ✗ | } | |
| 1813 | else | ||
| 1814 | { | ||
| 1815 | ✗ | wx = x; | |
| 1816 | ✗ | wy = y; | |
| 1817 | } | ||
| 1818 | |||
| 1819 | ✗ | addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez); | |
| 1820 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 1821 | |||
| 1822 | ✗ | int32_t i=Ewpns.Count()-1; | |
| 1823 | ✗ | weapon *ew = (weapon*)(Ewpns.spr(i)); | |
| 1824 | ✗ | ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 1825 | |||
| 1826 | ✗ | if(!seekhero && (zc_oldrand()&4)) | |
| 1827 | { | ||
| 1828 | ✗ | ew->angular=true; | |
| 1829 | ✗ | ew->angle=fire_angle; | |
| 1830 | ✗ | } | |
| 1831 | |||
| 1832 | ✗ | if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1) | |
| 1833 | { | ||
| 1834 | ✗ | ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames; | |
| 1835 | ✗ | if ( ew->do_animation ) ew->tile+=ew->aframe; | |
| 1836 | ✗ | } | |
| 1837 | |||
| 1838 | ✗ | for(int32_t j=Ewpns.Count()-1; j>0; j--) | |
| 1839 | { | ||
| 1840 | ✗ | Ewpns.swap(j,j-1); | |
| 1841 | ✗ | } | |
| 1842 | ✗ | } | |
| 1843 | |||
| 1844 | 970 | void enemy::FireWeapon() | |
| 1845 | { | ||
| 1846 | /* | ||
| 1847 | * Type: | ||
| 1848 | * 0x01: Boss fireball | ||
| 1849 | * 0x02: Seeks Hero | ||
| 1850 | * 0x04: Fast projectile | ||
| 1851 | * 0x00-0x30: If 0x02, slants toward (type>>3)-1 | ||
| 1852 | */ | ||
| 1853 | |||
| 1854 |
1/2✓ Branch 0 taken 970 times.
✗ Branch 1 not taken.
|
970 | if (wpn < 1) return; |
| 1855 |
1/10✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
970 | if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons |
| 1856 | ✗ | return; | |
| 1857 | |||
| 1858 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
970 | if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS) |
| 1859 | ✗ | dmisc1 = e1tEACHTILE; | |
| 1860 | |||
| 1861 | 970 | int32_t xoff = 0; | |
| 1862 | 970 | int32_t yoff = 0; | |
| 1863 |
1/2✓ Branch 0 taken 970 times.
✗ Branch 1 not taken.
|
970 | if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH ) |
| 1864 | { | ||
| 1865 | ✗ | xoff += (hit_width/2)-8; | |
| 1866 | //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff); | ||
| 1867 | ✗ | } | |
| 1868 |
1/2✓ Branch 0 taken 970 times.
✗ Branch 1 not taken.
|
970 | if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT ) |
| 1869 | { | ||
| 1870 | ✗ | yoff += (hit_height/2)-8; | |
| 1871 | //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff); | ||
| 1872 | ✗ | } | |
| 1873 | |||
| 1874 |
2/8✗ Branch 0 not taken.
✓ Branch 1 taken 968 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
970 | switch(dmisc1) |
| 1875 | { | ||
| 1876 | case e1t5SHOTS: //BS-Aquamentus | ||
| 1877 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false)); | |
| 1878 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1879 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false)); | |
| 1880 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1881 | |||
| 1882 | [[fallthrough]]; | ||
| 1883 | case e1t3SHOTSFAST: | ||
| 1884 | case e1t3SHOTS: //Aquamentus | ||
| 1885 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false)); | |
| 1886 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1887 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false)); | |
| 1888 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1889 | |||
| 1890 | [[fallthrough]]; | ||
| 1891 | default: | ||
| 1892 |
11/20✓ Branch 0 taken 968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 968 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 968 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 968 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 968 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 968 times.
✓ Branch 12 taken 968 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 266 times.
✓ Branch 15 taken 702 times.
✓ Branch 16 taken 968 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 968 times.
✗ Branch 19 not taken.
|
968 | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false)); |
| 1893 | 968 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1894 | 968 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 1895 | 968 | break; | |
| 1896 | |||
| 1897 | case e1tSLANT: | ||
| 1898 | { | ||
| 1899 | ✗ | int32_t slant = 0; | |
| 1900 | |||
| 1901 | ✗ | if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right)) | |
| 1902 | ✗ | slant = left; | |
| 1903 | ✗ | else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right)) | |
| 1904 | ✗ | slant = right; | |
| 1905 | |||
| 1906 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false)); | |
| 1907 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1908 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 1909 | ✗ | break; | |
| 1910 | } | ||
| 1911 | |||
| 1912 | case e1t8SHOTS: //Fire Wizzrobe | ||
| 1913 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false)); | |
| 1914 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1915 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 1916 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false)); | |
| 1917 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1918 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 1919 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false)); | |
| 1920 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1921 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 1922 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false)); | |
| 1923 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1924 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 1925 | |||
| 1926 | [[fallthrough]]; | ||
| 1927 | case e1t4SHOTS: //Stalfos 3 | ||
| 1928 |
7/14✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
|
2 | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false)); |
| 1929 | 2 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1930 | 2 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 1931 |
7/14✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
|
2 | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false)); |
| 1932 | 2 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1933 | 2 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 1934 |
7/14✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
|
2 | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false)); |
| 1935 | 2 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1936 | 2 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 1937 |
7/14✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
|
2 | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false)); |
| 1938 | 2 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 1939 | 2 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 1940 | 2 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 1941 | 2 | break; | |
| 1942 | |||
| 1943 | case e1tSUMMON: // Bat Wizzrobe | ||
| 1944 | { | ||
| 1945 | //al_trace("Summon Bats\n"); | ||
| 1946 | //zprint2("Summon Bats\n"); | ||
| 1947 | ✗ | if(dmisc4==0) break; // Summon 0 | |
| 1948 | |||
| 1949 | ✗ | int32_t bc=0; | |
| 1950 | |||
| 1951 | ✗ | for(int32_t gc=0; gc<guys.Count(); gc++) | |
| 1952 | { | ||
| 1953 | ✗ | if((((enemy*)guys.spr(gc))->id) == dmisc3) | |
| 1954 | { | ||
| 1955 | ✗ | ++bc; | |
| 1956 | ✗ | } | |
| 1957 | ✗ | } | |
| 1958 | |||
| 1959 | ✗ | if(bc<=40) // Not too many enemies | |
| 1960 | { | ||
| 1961 | ✗ | int32_t kids = guys.Count(); | |
| 1962 | ✗ | int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1; | |
| 1963 | |||
| 1964 | ✗ | for(int32_t i=0; i<bats; i++) | |
| 1965 | { | ||
| 1966 | //zprint2("summon\n"); | ||
| 1967 | //al_trace("summon\n"); | ||
| 1968 | ✗ | if(addchild(x,y,dmisc3,-10, this->script_UID)) | |
| 1969 | { | ||
| 1970 | ✗ | ((enemy*)guys.spr(kids+i))->count_enemy = false; | |
| 1971 | //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID; | ||
| 1972 | //zprint2("Summoner Script UID: %d\n",this->script_UID); | ||
| 1973 | |||
| 1974 | ✗ | } | |
| 1975 | ✗ | } | |
| 1976 | |||
| 1977 | ✗ | sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x))); | |
| 1978 | ✗ | } | |
| 1979 | |||
| 1980 | ✗ | break; | |
| 1981 | } | ||
| 1982 | |||
| 1983 | case e1tSUMMONLAYER: // Summoner | ||
| 1984 | { | ||
| 1985 | ✗ | if(count_layer_enemies()==0) | |
| 1986 | { | ||
| 1987 | ✗ | break; | |
| 1988 | } | ||
| 1989 | |||
| 1990 | ✗ | int32_t kids = guys.Count(); | |
| 1991 | |||
| 1992 | ✗ | if(kids<40) | |
| 1993 | { | ||
| 1994 | ✗ | int32_t newguys=(zc_oldrand()%3)+1; | |
| 1995 | ✗ | bool summoned=false; | |
| 1996 | |||
| 1997 | ✗ | for(int32_t i=0; i<newguys; i++) | |
| 1998 | { | ||
| 1999 | ✗ | int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1); | |
| 2000 | ✗ | int32_t x2=0; | |
| 2001 | ✗ | int32_t y2=0; | |
| 2002 | |||
| 2003 | ✗ | for(int32_t k=0; k<20; ++k) | |
| 2004 | { | ||
| 2005 | ✗ | x2=16*((zc_oldrand()%12)+2); | |
| 2006 | ✗ | y2=16*((zc_oldrand()%7)+2); | |
| 2007 | |||
| 2008 | ✗ | if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32))) | |
| 2009 | { | ||
| 2010 | //zprint2("summon\n"); | ||
| 2011 | //al_trace("summon\n"); | ||
| 2012 | ✗ | if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID)) | |
| 2013 | { | ||
| 2014 | ✗ | ((enemy*)guys.spr(kids+i))->count_enemy = false; | |
| 2015 | //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID; | ||
| 2016 | ✗ | if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z)) | |
| 2017 | { | ||
| 2018 | ✗ | ((enemy*)guys.spr(kids+i))->fakez = 64; | |
| 2019 | ✗ | ((enemy*)guys.spr(kids+i))->z = 0; | |
| 2020 | ✗ | } | |
| 2021 | ✗ | } | |
| 2022 | |||
| 2023 | ✗ | summoned=true; | |
| 2024 | ✗ | break; | |
| 2025 | } | ||
| 2026 | ✗ | } | |
| 2027 | ✗ | } | |
| 2028 | |||
| 2029 | ✗ | if(summoned) | |
| 2030 | { | ||
| 2031 | ✗ | sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x))); | |
| 2032 | ✗ | } | |
| 2033 | ✗ | } | |
| 2034 | |||
| 2035 | ✗ | break; | |
| 2036 | } | ||
| 2037 | } | ||
| 2038 | 970 | } | |
| 2039 | |||
| 2040 | |||
| 2041 | // Hit the shield(s)? | ||
| 2042 | // Apparently, this function is only used for hookshots... | ||
| 2043 | ✗ | bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir) | |
| 2044 | { | ||
| 2045 | ✗ | if(!(family==eeWALK || family==eeFIRE || family==eeOTHER)) | |
| 2046 | ✗ | return false; | |
| 2047 | |||
| 2048 | ✗ | bool ret = false; | |
| 2049 | |||
| 2050 | // TODO: There must be some bitwise operations that can simplify this... | ||
| 2051 | ✗ | if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right)); | |
| 2052 | ✗ | else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left)); | |
| 2053 | |||
| 2054 | ✗ | if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down)); | |
| 2055 | ✗ | else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up)); | |
| 2056 | |||
| 2057 | ✗ | return ret; | |
| 2058 | ✗ | } | |
| 2059 | |||
| 2060 | |||
| 2061 | //! Weapon Editor for 2.6 | ||
| 2062 | //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z | ||
| 2063 | |||
| 2064 | |||
| 2065 | //converts a wqeapon ID to its defence index. | ||
| 2066 | 2758 | int32_t weaponToDefence(int32_t wid) | |
| 2067 | { | ||
| 2068 |
7/47✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
✓ Branch 2 taken 511 times.
✓ Branch 3 taken 406 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 29 times.
✓ Branch 9 taken 226 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
|
2758 | switch(wid) |
| 2069 | { | ||
| 2070 | ✗ | case wNone: return -1; | |
| 2071 | 1576 | case wSword: return edefSWORD; | |
| 2072 | 511 | case wBeam: return edefBEAM; | |
| 2073 | 406 | case wBrang: return edefBRANG; | |
| 2074 | 9 | case wBomb: return edefBOMB; | |
| 2075 | ✗ | case wSBomb: return edefSBOMB; | |
| 2076 | ✗ | case wLitBomb: return edefBOMB; | |
| 2077 | ✗ | case wLitSBomb: return edefSBOMB; | |
| 2078 | 29 | case wArrow: return edefARROW; | |
| 2079 | 226 | case wFire: return edefFIRE; | |
| 2080 | case wWhistle: | ||
| 2081 | { | ||
| 2082 | //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle"); | ||
| 2083 | ✗ | return edefWhistle; | |
| 2084 | } | ||
| 2085 | ✗ | case wBait: return edefBAIT; | |
| 2086 | ✗ | case wWand: return edefWAND; | |
| 2087 | ✗ | case wMagic: return edefMAGIC; | |
| 2088 | ✗ | case wCatching: return -1; | |
| 2089 | ✗ | case wWind: return edefWIND; | |
| 2090 | ✗ | case wRefMagic: return edefREFMAGIC; | |
| 2091 | 1 | case wRefFireball: return edefREFBALL; | |
| 2092 | ✗ | case wRefRock: return edefREFROCK; | |
| 2093 | ✗ | case wHammer: return edefHAMMER; | |
| 2094 | ✗ | case wHookshot: return edefHOOKSHOT; | |
| 2095 | ✗ | case wHSHandle: return edefHOOKSHOT; | |
| 2096 | ✗ | case wHSChain: return edefHOOKSHOT; | |
| 2097 | ✗ | case wSSparkle: return edefSPARKLE; | |
| 2098 | ✗ | case wFSparkle: return edefSPARKLE; | |
| 2099 | ✗ | case wSmack: return -1; // is this the candle object? | |
| 2100 | ✗ | case wPhantom: return -1; //engine created visual effects. | |
| 2101 | ✗ | case wCByrna: return edefBYRNA; | |
| 2102 | ✗ | case wRefBeam: return edefREFBEAM; | |
| 2103 | ✗ | case wStomp: return edefSTOMP; | |
| 2104 | ✗ | case wScript1: return edefSCRIPT01; | |
| 2105 | ✗ | case wScript2: return edefSCRIPT02; | |
| 2106 | ✗ | case wScript3: return edefSCRIPT03; | |
| 2107 | ✗ | case wScript4: return edefSCRIPT04; | |
| 2108 | ✗ | case wScript5: return edefSCRIPT05; | |
| 2109 | ✗ | case wScript6: return edefSCRIPT06; | |
| 2110 | ✗ | case wScript7: return edefSCRIPT07; | |
| 2111 | ✗ | case wScript8: return edefSCRIPT08; | |
| 2112 | ✗ | case wScript9: return edefSCRIPT09; | |
| 2113 | ✗ | case wScript10: return edefSCRIPT10; | |
| 2114 | ✗ | case wIce: return edefICE; | |
| 2115 | ✗ | case wSound: return edefSONIC; | |
| 2116 | ✗ | case wThrown: return edefTHROWN; | |
| 2117 | ✗ | case wRefArrow: return edefREFARROW; | |
| 2118 | ✗ | case wRefFire: return edefREFFIRE; | |
| 2119 | ✗ | case wRefFire2: return edefREFFIRE2; | |
| 2120 | //case wPot: return edefPOT; | ||
| 2121 | // case wLitZap: return edefELECTRIC; | ||
| 2122 | // case wZ3Sword: return edefZ3SWORD; | ||
| 2123 | // case wLASWord: return edefLASWORD; | ||
| 2124 | // case wSpinAttk: return edefSPINATTK; | ||
| 2125 | // case wShield: return edefSHIELD; | ||
| 2126 | // case wTrowel: return edefTROWEL; | ||
| 2127 | |||
| 2128 | ✗ | default: return -1; | |
| 2129 | } | ||
| 2130 | 2758 | } | |
| 2131 | |||
| 2132 | 2758 | int32_t getDefType(weapon *w) | |
| 2133 | { | ||
| 2134 | 2758 | int32_t id = getWeaponID(w); | |
| 2135 | 2758 | int32_t edef = weaponToDefence(id); | |
| 2136 |
1/2✓ Branch 0 taken 2758 times.
✗ Branch 1 not taken.
|
2758 | if(edef == edefHOOKSHOT) |
| 2137 | { | ||
| 2138 | ✗ | if(w->family_class == itype_switchhook) | |
| 2139 | ✗ | return edefSwitchHook; | |
| 2140 | ✗ | } | |
| 2141 | 2758 | return edef; | |
| 2142 | 2758 | } | |
| 2143 | |||
| 2144 | 5110 | int32_t getWeaponID(weapon *w) | |
| 2145 | { | ||
| 2146 | 5110 | int32_t usewpn = w->useweapon; | |
| 2147 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5110 times.
|
5110 | return (usewpn > 0) ? usewpn : w->id; |
| 2148 | } | ||
| 2149 | |||
| 2150 | 2758 | int32_t enemy::resolveEnemyDefence(weapon *w) | |
| 2151 | { | ||
| 2152 | //sword edef is 9, but we're reading it at 0 | ||
| 2153 | //, | ||
| 2154 | 2758 | int32_t weapondef = 0; | |
| 2155 | 2758 | int32_t wdeftype = getDefType(w); | |
| 2156 | 2758 | int32_t usedef = w->usedefence; | |
| 2157 | |||
| 2158 |
1/8✗ Branch 0 not taken.
✓ Branch 1 taken 2758 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
2758 | if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0)) |
| 2159 | { | ||
| 2160 | ✗ | weapondef = usedef*-1; | |
| 2161 | ✗ | } | |
| 2162 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2758 times.
|
2758 | else if(unsigned(wdeftype) < edefLAST255) |
| 2163 | { | ||
| 2164 | 2758 | weapondef = wdeftype; | |
| 2165 | 2758 | } | |
| 2166 | 2758 | return weapondef; | |
| 2167 | } | ||
| 2168 | |||
| 2169 | 2879 | byte get_def_ignrflag(int32_t edef) | |
| 2170 | { | ||
| 2171 |
3/3✓ Branch 0 taken 2526 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 331 times.
|
2879 | switch(edef) |
| 2172 | { | ||
| 2173 | case edIGNORE: | ||
| 2174 | case edIGNOREL1: | ||
| 2175 | case edSTUNORIGNORE: | ||
| 2176 | 331 | return WPNUNB_IGNR; | |
| 2177 | case edSTUNORCHINK: | ||
| 2178 | case edCHINK: | ||
| 2179 | case edCHINKL1: | ||
| 2180 | case edCHINKL2: | ||
| 2181 | case edCHINKL4: | ||
| 2182 | case edCHINKL6: | ||
| 2183 | case edCHINKL8: | ||
| 2184 | case edCHINKL10: | ||
| 2185 | case edLEVELCHINK2: | ||
| 2186 | case edLEVELCHINK3: | ||
| 2187 | case edLEVELCHINK4: | ||
| 2188 | case edLEVELCHINK5: | ||
| 2189 | 22 | return WPNUNB_BLOCK; | |
| 2190 | } | ||
| 2191 | 2526 | return 0; | |
| 2192 | 2879 | } | |
| 2193 | |||
| 2194 | 2879 | int32_t conv_edef_unblockable(int32_t edef, byte unblockable) | |
| 2195 | { | ||
| 2196 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2879 times.
|
2879 | if(!(unblockable&get_def_ignrflag(edef))) return edef; |
| 2197 | ✗ | switch(edef) | |
| 2198 | { | ||
| 2199 | case edIGNORE: | ||
| 2200 | case edIGNOREL1: | ||
| 2201 | case edCHINK: | ||
| 2202 | case edCHINKL1: | ||
| 2203 | case edCHINKL2: | ||
| 2204 | case edCHINKL4: | ||
| 2205 | case edCHINKL6: | ||
| 2206 | case edCHINKL8: | ||
| 2207 | case edCHINKL10: | ||
| 2208 | case edLEVELCHINK2: | ||
| 2209 | case edLEVELCHINK3: | ||
| 2210 | case edLEVELCHINK4: | ||
| 2211 | case edLEVELCHINK5: | ||
| 2212 | ✗ | return edNORMAL; | |
| 2213 | case edSTUNORIGNORE: | ||
| 2214 | case edSTUNORCHINK: | ||
| 2215 | ✗ | return edSTUNONLY; | |
| 2216 | } | ||
| 2217 | ✗ | return edef; | |
| 2218 | 2879 | } | |
| 2219 | |||
| 2220 | // Do we do damage? | ||
| 2221 | // 0: takehit returns 0 | ||
| 2222 | // 1: takehit returns 1 | ||
| 2223 | // -1: do damage | ||
| 2224 | //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used. | ||
| 2225 | 2758 | int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots | |
| 2226 | { | ||
| 2227 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2758 times.
|
2758 | if(switch_hooked) return 0; |
| 2228 | 2758 | int32_t tempx = x; | |
| 2229 | 2758 | int32_t tempy = y; | |
| 2230 | 2758 | int32_t the_defence = 0; | |
| 2231 |
1/2✓ Branch 0 taken 2758 times.
✗ Branch 1 not taken.
|
2758 | if ( edef < 0 ) //we are using a specific base default defence for a weapon |
| 2232 | { | ||
| 2233 | ✗ | the_defence = edef*-1; //A specific defence type. | |
| 2234 | ✗ | } | |
| 2235 | 2758 | else the_defence = defense[edef]; | |
| 2236 | |||
| 2237 | 2758 | the_defence = conv_edef_unblockable(the_defence, unblockable); | |
| 2238 | |||
| 2239 |
3/4✓ Branch 0 taken 112 times.
✓ Branch 1 taken 2646 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
|
2758 | if(shieldCanBlock && !(unblockable&WPNUNB_SHLD)) |
| 2240 | { | ||
| 2241 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
|
112 | switch(the_defence) |
| 2242 | { | ||
| 2243 | case edIGNORE: | ||
| 2244 | ✗ | return 0; | |
| 2245 | case edIGNOREL1: | ||
| 2246 | case edSTUNORIGNORE: | ||
| 2247 | ✗ | if(*power <= 0) | |
| 2248 | ✗ | return 0; | |
| 2249 | ✗ | } | |
| 2250 | 112 | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 2251 | 112 | return 1; | |
| 2252 | } | ||
| 2253 | |||
| 2254 | 2646 | int32_t new_id = id; | |
| 2255 | 2646 | int32_t effect_type = dmisc15; | |
| 2256 | 2646 | int32_t delay_timer = 90; | |
| 2257 | 2646 | enemy *gleeok = NULL; | |
| 2258 | 2646 | enemy *ptra = NULL; | |
| 2259 | 2646 | int32_t c = 0; | |
| 2260 | |||
| 2261 |
6/29✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 331 times.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 21 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 2181 times.
|
2646 | switch(the_defence) |
| 2262 | { | ||
| 2263 | case edREPLACE: | ||
| 2264 | { | ||
| 2265 | ✗ | sclk = 0; | |
| 2266 | ✗ | if ( dmisc16 > 0 ) new_id = dmisc16; | |
| 2267 | ✗ | else new_id = id+1; | |
| 2268 | ✗ | if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs. | |
| 2269 | ✗ | if ( dmisc17 > 0 ) delay_timer = dmisc17; | |
| 2270 | //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18; | ||
| 2271 | |||
| 2272 | //Z_scripterrlog("new id is %d\n", new_id); | ||
| 2273 | ✗ | switch(guysbuf[new_id&0xFFF].family) | |
| 2274 | { | ||
| 2275 | //Fixme: possible enemy memory leak. (minor) | ||
| 2276 | case eeWALK: | ||
| 2277 | { | ||
| 2278 | ✗ | enemy *e = new eStalfos(x,y,new_id,clk); | |
| 2279 | ✗ | guys.add(e); | |
| 2280 | } | ||
| 2281 | ✗ | break; | |
| 2282 | |||
| 2283 | case eeLEV: | ||
| 2284 | { | ||
| 2285 | ✗ | enemy *e = new eLeever(x,y,new_id,clk); | |
| 2286 | ✗ | guys.add(e); | |
| 2287 | } | ||
| 2288 | ✗ | break; | |
| 2289 | |||
| 2290 | case eeTEK: | ||
| 2291 | { | ||
| 2292 | ✗ | enemy *e = new eTektite(x,y,new_id,clk); | |
| 2293 | ✗ | guys.add(e); | |
| 2294 | } | ||
| 2295 | ✗ | break; | |
| 2296 | |||
| 2297 | case eePEAHAT: | ||
| 2298 | { | ||
| 2299 | ✗ | enemy *e = new ePeahat(x,y,new_id,clk); | |
| 2300 | ✗ | guys.add(e); | |
| 2301 | } | ||
| 2302 | ✗ | break; | |
| 2303 | |||
| 2304 | case eeZORA: | ||
| 2305 | { | ||
| 2306 | ✗ | enemy *e = new eZora(x,y,new_id,clk); | |
| 2307 | ✗ | guys.add(e); | |
| 2308 | } | ||
| 2309 | ✗ | break; | |
| 2310 | |||
| 2311 | case eeGHINI: | ||
| 2312 | { | ||
| 2313 | ✗ | enemy *e = new eGhini(x,y,new_id,clk); | |
| 2314 | ✗ | guys.add(e); | |
| 2315 | } | ||
| 2316 | ✗ | break; | |
| 2317 | |||
| 2318 | case eeKEESE: | ||
| 2319 | { | ||
| 2320 | ✗ | enemy *e = new eKeese(x,y,new_id,clk); | |
| 2321 | ✗ | guys.add(e); | |
| 2322 | } | ||
| 2323 | ✗ | break; | |
| 2324 | |||
| 2325 | case eeWIZZ: | ||
| 2326 | { | ||
| 2327 | ✗ | enemy *e = new eWizzrobe(x,y,new_id,clk); | |
| 2328 | ✗ | guys.add(e); | |
| 2329 | } | ||
| 2330 | ✗ | break; | |
| 2331 | |||
| 2332 | case eePROJECTILE: | ||
| 2333 | { | ||
| 2334 | ✗ | enemy *e = new eProjectile(x,y,new_id,clk); | |
| 2335 | ✗ | guys.add(e); | |
| 2336 | } | ||
| 2337 | ✗ | break; | |
| 2338 | |||
| 2339 | case eeWALLM: | ||
| 2340 | { | ||
| 2341 | ✗ | enemy *e = new eWallM(x,y,new_id,clk); | |
| 2342 | ✗ | guys.add(e); | |
| 2343 | } | ||
| 2344 | ✗ | break; | |
| 2345 | |||
| 2346 | case eeAQUA: | ||
| 2347 | { | ||
| 2348 | ✗ | enemy *e = new eAquamentus(x,y,new_id,clk); | |
| 2349 | ✗ | guys.add(e); | |
| 2350 | ✗ | e->x = x; | |
| 2351 | ✗ | e->y = y; | |
| 2352 | } | ||
| 2353 | ✗ | break; | |
| 2354 | |||
| 2355 | case eeMOLD: | ||
| 2356 | { | ||
| 2357 | ✗ | enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1))); | |
| 2358 | ✗ | guys.add(e); | |
| 2359 | ✗ | e->x = x; | |
| 2360 | ✗ | e->y = y; | |
| 2361 | } | ||
| 2362 | ✗ | break; | |
| 2363 | |||
| 2364 | case eeMANHAN: | ||
| 2365 | { | ||
| 2366 | ✗ | enemy *e = new eManhandla(x,y,new_id,clk); | |
| 2367 | ✗ | guys.add(e); | |
| 2368 | ✗ | e->x = x; | |
| 2369 | ✗ | e->y = y; | |
| 2370 | } | ||
| 2371 | ✗ | break; | |
| 2372 | |||
| 2373 | case eeGLEEOK: | ||
| 2374 | { | ||
| 2375 | ✗ | *power = 0; | |
| 2376 | ✗ | gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1); | |
| 2377 | ✗ | guys.add(gleeok); | |
| 2378 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer; | |
| 2379 | //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer; | ||
| 2380 | ✗ | new_id &= 0xFFF; | |
| 2381 | ✗ | int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)); | |
| 2382 | ✗ | Z_scripterrlog("Gleeok head count is %d\n",head_cnt); | |
| 2383 | ✗ | for(int32_t i=0; i<head_cnt; i++) | |
| 2384 | { | ||
| 2385 | //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok); | ||
| 2386 | ✗ | if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok))) | |
| 2387 | { | ||
| 2388 | ✗ | al_trace("Gleeok head %d could not be created!\n",i+1); | |
| 2389 | |||
| 2390 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 2391 | { | ||
| 2392 | ✗ | guys.del(guys.Count()-1); | |
| 2393 | ✗ | } | |
| 2394 | |||
| 2395 | ✗ | break; | |
| 2396 | } | ||
| 2397 | else | ||
| 2398 | { | ||
| 2399 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer; | |
| 2400 | //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer; | ||
| 2401 | } | ||
| 2402 | |||
| 2403 | ✗ | c-=guysbuf[new_id].misc4; | |
| 2404 | //gleeok->x = x; | ||
| 2405 | //gleeok->y = y; | ||
| 2406 | //gleeok = e; | ||
| 2407 | ✗ | } | |
| 2408 | ✗ | return 1; | |
| 2409 | } | ||
| 2410 | |||
| 2411 | case eeGHOMA: | ||
| 2412 | { | ||
| 2413 | ✗ | enemy *e = new eGohma(x,y,new_id,clk); | |
| 2414 | ✗ | guys.add(e); | |
| 2415 | ✗ | e->x = x; | |
| 2416 | ✗ | e->y = y; | |
| 2417 | } | ||
| 2418 | ✗ | break; | |
| 2419 | |||
| 2420 | case eeLANM: | ||
| 2421 | { | ||
| 2422 | ✗ | enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1))); | |
| 2423 | ✗ | guys.add(e); | |
| 2424 | ✗ | e->x = x; | |
| 2425 | ✗ | e->y = y; | |
| 2426 | } | ||
| 2427 | ✗ | break; | |
| 2428 | |||
| 2429 | case eeGANON: | ||
| 2430 | { | ||
| 2431 | ✗ | enemy *e = new eGanon(x,y,new_id,clk); | |
| 2432 | ✗ | guys.add(e); | |
| 2433 | ✗ | e->x = x; | |
| 2434 | ✗ | e->y = y; | |
| 2435 | } | ||
| 2436 | ✗ | break; | |
| 2437 | |||
| 2438 | case eeFAIRY: | ||
| 2439 | { | ||
| 2440 | ✗ | enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk); | |
| 2441 | ✗ | guys.add(e); | |
| 2442 | ✗ | e->x = x; | |
| 2443 | ✗ | e->y = y; | |
| 2444 | } | ||
| 2445 | ✗ | break; | |
| 2446 | |||
| 2447 | case eeFIRE: | ||
| 2448 | { | ||
| 2449 | ✗ | enemy *e = new eFire(x,y,new_id,clk); | |
| 2450 | ✗ | guys.add(e); | |
| 2451 | ✗ | e->x = x; | |
| 2452 | ✗ | e->y = y; | |
| 2453 | } | ||
| 2454 | ✗ | break; | |
| 2455 | |||
| 2456 | case eeOTHER: | ||
| 2457 | { | ||
| 2458 | ✗ | enemy *e = new eOther(x,y,new_id,clk); | |
| 2459 | ✗ | guys.add(e); | |
| 2460 | ✗ | e->x = x; | |
| 2461 | ✗ | e->y = y; | |
| 2462 | } | ||
| 2463 | ✗ | break; | |
| 2464 | |||
| 2465 | case eeSPINTILE: | ||
| 2466 | { | ||
| 2467 | ✗ | enemy *e = new eSpinTile(x,y,new_id,clk); | |
| 2468 | ✗ | guys.add(e); | |
| 2469 | ✗ | e->x = x; | |
| 2470 | ✗ | e->y = y; | |
| 2471 | } | ||
| 2472 | ✗ | break; | |
| 2473 | |||
| 2474 | // and these enemies use the misc10/misc2 value | ||
| 2475 | case eeROCK: | ||
| 2476 | { | ||
| 2477 | ✗ | switch(guysbuf[new_id&0xFFF].misc10) | |
| 2478 | { | ||
| 2479 | case 1: | ||
| 2480 | { | ||
| 2481 | ✗ | enemy *e = new eBoulder(x,y,new_id,clk); | |
| 2482 | ✗ | guys.add(e); | |
| 2483 | ✗ | e->x = x; | |
| 2484 | ✗ | e->y = y; | |
| 2485 | } | ||
| 2486 | ✗ | break; | |
| 2487 | |||
| 2488 | ✗ | case 0: | |
| 2489 | default: | ||
| 2490 | { | ||
| 2491 | ✗ | enemy *e = new eRock(x,y,new_id,clk); | |
| 2492 | ✗ | guys.add(e); | |
| 2493 | ✗ | e->x = x; | |
| 2494 | ✗ | e->y = y; | |
| 2495 | } | ||
| 2496 | ✗ | break; | |
| 2497 | } | ||
| 2498 | |||
| 2499 | ✗ | break; | |
| 2500 | } | ||
| 2501 | |||
| 2502 | case eeTRAP: | ||
| 2503 | { | ||
| 2504 | ✗ | switch(guysbuf[new_id&0xFFF].misc2) | |
| 2505 | { | ||
| 2506 | case 1: | ||
| 2507 | { | ||
| 2508 | ✗ | enemy *e = new eTrap2(x,y,new_id,clk); | |
| 2509 | ✗ | guys.add(e); | |
| 2510 | ✗ | e->x = x; | |
| 2511 | ✗ | e->y = y; | |
| 2512 | } | ||
| 2513 | ✗ | break; | |
| 2514 | |||
| 2515 | ✗ | case 0: | |
| 2516 | default: | ||
| 2517 | { | ||
| 2518 | ✗ | enemy *e = new eTrap(x,y,new_id,clk); | |
| 2519 | ✗ | guys.add(e); | |
| 2520 | ✗ | e->x = x; | |
| 2521 | ✗ | e->y = y; | |
| 2522 | } | ||
| 2523 | ✗ | break; | |
| 2524 | } | ||
| 2525 | |||
| 2526 | ✗ | break; | |
| 2527 | } | ||
| 2528 | |||
| 2529 | case eeDONGO: | ||
| 2530 | { | ||
| 2531 | ✗ | switch(guysbuf[new_id&0xFFF].misc10) | |
| 2532 | { | ||
| 2533 | case 1: | ||
| 2534 | { | ||
| 2535 | ✗ | enemy *e = new eDodongo2(x,y,new_id,clk); | |
| 2536 | ✗ | guys.add(e); | |
| 2537 | ✗ | e->x = x; | |
| 2538 | ✗ | e->y = y; | |
| 2539 | } | ||
| 2540 | ✗ | break; | |
| 2541 | |||
| 2542 | ✗ | case 0: | |
| 2543 | default: | ||
| 2544 | { | ||
| 2545 | ✗ | enemy *e = new eDodongo(x,y,new_id,clk); | |
| 2546 | ✗ | guys.add(e); | |
| 2547 | ✗ | e->x = x; | |
| 2548 | ✗ | e->y = y; | |
| 2549 | } | ||
| 2550 | ✗ | break; | |
| 2551 | } | ||
| 2552 | |||
| 2553 | ✗ | break; | |
| 2554 | } | ||
| 2555 | |||
| 2556 | case eeDIG: | ||
| 2557 | { | ||
| 2558 | ✗ | switch(guysbuf[new_id&0xFFF].misc10) | |
| 2559 | { | ||
| 2560 | case 1: | ||
| 2561 | { | ||
| 2562 | ✗ | enemy *e = new eLilDig(x,y,new_id,clk); | |
| 2563 | ✗ | guys.add(e); | |
| 2564 | ✗ | e->x = x; | |
| 2565 | ✗ | e->y = y; | |
| 2566 | } | ||
| 2567 | ✗ | break; | |
| 2568 | |||
| 2569 | ✗ | case 0: | |
| 2570 | default: | ||
| 2571 | { | ||
| 2572 | ✗ | enemy *e = new eBigDig(x,y,new_id,clk); | |
| 2573 | ✗ | guys.add(e); | |
| 2574 | ✗ | e->x = x; | |
| 2575 | ✗ | e->y = y; | |
| 2576 | } | ||
| 2577 | ✗ | break; | |
| 2578 | } | ||
| 2579 | |||
| 2580 | ✗ | break; | |
| 2581 | } | ||
| 2582 | |||
| 2583 | case eePATRA: | ||
| 2584 | { | ||
| 2585 | ✗ | switch(guysbuf[new_id&0xFFF].misc10) | |
| 2586 | { | ||
| 2587 | case 1: | ||
| 2588 | { | ||
| 2589 | ✗ | if (get_qr(qr_HARDCODED_BS_PATRA)) | |
| 2590 | { | ||
| 2591 | ✗ | enemy *e = new ePatraBS(x,y,new_id,clk); | |
| 2592 | ✗ | guys.add(e); | |
| 2593 | ✗ | e->x = x; | |
| 2594 | ✗ | e->y = y; | |
| 2595 | ✗ | break; | |
| 2596 | } | ||
| 2597 | ✗ | } | |
| 2598 | [[fallthrough]]; | ||
| 2599 | ✗ | case 0: | |
| 2600 | default: | ||
| 2601 | { | ||
| 2602 | ✗ | enemy *e = new ePatra(x,y,new_id,clk); | |
| 2603 | ✗ | guys.add(e); | |
| 2604 | ✗ | e->x = x; | |
| 2605 | ✗ | e->y = y; | |
| 2606 | } | ||
| 2607 | ✗ | break; | |
| 2608 | } | ||
| 2609 | |||
| 2610 | ✗ | break; | |
| 2611 | } | ||
| 2612 | |||
| 2613 | case eeGUY: | ||
| 2614 | { | ||
| 2615 | ✗ | switch(guysbuf[new_id&0xFFF].misc10) | |
| 2616 | { | ||
| 2617 | case 1: | ||
| 2618 | { | ||
| 2619 | ✗ | enemy *e = new eTrigger(x,y,new_id,clk); | |
| 2620 | ✗ | guys.add(e); | |
| 2621 | } | ||
| 2622 | ✗ | break; | |
| 2623 | |||
| 2624 | ✗ | case 0: | |
| 2625 | default: | ||
| 2626 | { | ||
| 2627 | ✗ | enemy *e = new eNPC(x,y,new_id,clk); | |
| 2628 | ✗ | guys.add(e); | |
| 2629 | } | ||
| 2630 | ✗ | break; | |
| 2631 | } | ||
| 2632 | |||
| 2633 | ✗ | break; | |
| 2634 | } | ||
| 2635 | |||
| 2636 | case eeSCRIPT01: | ||
| 2637 | case eeSCRIPT02: | ||
| 2638 | case eeSCRIPT03: | ||
| 2639 | case eeSCRIPT04: | ||
| 2640 | case eeSCRIPT05: | ||
| 2641 | case eeSCRIPT06: | ||
| 2642 | case eeSCRIPT07: | ||
| 2643 | case eeSCRIPT08: | ||
| 2644 | case eeSCRIPT09: | ||
| 2645 | case eeSCRIPT10: | ||
| 2646 | case eeSCRIPT11: | ||
| 2647 | case eeSCRIPT12: | ||
| 2648 | case eeSCRIPT13: | ||
| 2649 | case eeSCRIPT14: | ||
| 2650 | case eeSCRIPT15: | ||
| 2651 | case eeSCRIPT16: | ||
| 2652 | case eeSCRIPT17: | ||
| 2653 | case eeSCRIPT18: | ||
| 2654 | case eeSCRIPT19: | ||
| 2655 | case eeSCRIPT20: | ||
| 2656 | { | ||
| 2657 | ✗ | enemy *e = new eScript(x,y,new_id,clk); | |
| 2658 | ✗ | guys.add(e); | |
| 2659 | ✗ | e->x = x; | |
| 2660 | ✗ | e->y = y; | |
| 2661 | ✗ | break; | |
| 2662 | } | ||
| 2663 | |||
| 2664 | |||
| 2665 | case eeFFRIENDLY01: | ||
| 2666 | case eeFFRIENDLY02: | ||
| 2667 | case eeFFRIENDLY03: | ||
| 2668 | case eeFFRIENDLY04: | ||
| 2669 | case eeFFRIENDLY05: | ||
| 2670 | case eeFFRIENDLY06: | ||
| 2671 | case eeFFRIENDLY07: | ||
| 2672 | case eeFFRIENDLY08: | ||
| 2673 | case eeFFRIENDLY09: | ||
| 2674 | case eeFFRIENDLY10: | ||
| 2675 | { | ||
| 2676 | ✗ | enemy *e = new eFriendly(x,y,new_id,clk); | |
| 2677 | ✗ | guys.add(e); | |
| 2678 | ✗ | e->x = x; | |
| 2679 | ✗ | e->y = y; | |
| 2680 | ✗ | break; | |
| 2681 | } | ||
| 2682 | |||
| 2683 | |||
| 2684 | ✗ | default: break; | |
| 2685 | } | ||
| 2686 | |||
| 2687 | // add segments of segmented enemies | ||
| 2688 | ✗ | int32_t c=0; | |
| 2689 | |||
| 2690 | ✗ | switch(guysbuf[new_id&0xFFF].family) | |
| 2691 | { | ||
| 2692 | case eeMOLD: | ||
| 2693 | { | ||
| 2694 | ✗ | byte is=((enemy*)guys.spr(guys.Count()-1))->item_set; | |
| 2695 | ✗ | new_id &= 0xFFF; | |
| 2696 | |||
| 2697 | ✗ | for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++) | |
| 2698 | { | ||
| 2699 | //christ this is messy -DD | ||
| 2700 | ✗ | int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100)))); | |
| 2701 | |||
| 2702 | ✗ | if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk))) | |
| 2703 | { | ||
| 2704 | ✗ | al_trace("Moldorm segment %d could not be created!\n",i+1); | |
| 2705 | |||
| 2706 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 2707 | ✗ | guys.del(guys.Count()-1); | |
| 2708 | |||
| 2709 | ✗ | return 0; | |
| 2710 | } | ||
| 2711 | |||
| 2712 | ✗ | if(i>0) | |
| 2713 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->item_set=is; | |
| 2714 | |||
| 2715 | |||
| 2716 | ✗ | } | |
| 2717 | |||
| 2718 | ✗ | break; | |
| 2719 | } | ||
| 2720 | |||
| 2721 | case eeLANM: | ||
| 2722 | { | ||
| 2723 | ✗ | new_id &= 0xFFF; | |
| 2724 | ✗ | int32_t shft = guysbuf[new_id].misc2; | |
| 2725 | ✗ | byte is=((enemy*)guys.spr(guys.Count()-1))->item_set; | |
| 2726 | ✗ | enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0); | |
| 2727 | |||
| 2728 | ✗ | if(!guys.add(e)) | |
| 2729 | { | ||
| 2730 | ✗ | al_trace("Lanmola segment 1 could not be created!\n"); | |
| 2731 | ✗ | guys.del(guys.Count()-1); | |
| 2732 | ✗ | return 0; | |
| 2733 | } | ||
| 2734 | ✗ | e->x = x; | |
| 2735 | ✗ | e->y = y; | |
| 2736 | |||
| 2737 | |||
| 2738 | |||
| 2739 | ✗ | for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++) | |
| 2740 | { | ||
| 2741 | ✗ | enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft)); | |
| 2742 | ✗ | if(!guys.add(e2)) | |
| 2743 | { | ||
| 2744 | ✗ | al_trace("Lanmola segment %d could not be created!\n",i+1); | |
| 2745 | |||
| 2746 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 2747 | ✗ | guys.del(guys.Count()-1); | |
| 2748 | |||
| 2749 | ✗ | return 0; | |
| 2750 | } | ||
| 2751 | ✗ | e2->x = x; | |
| 2752 | ✗ | e2->y = y; | |
| 2753 | |||
| 2754 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->item_set=is; | |
| 2755 | |||
| 2756 | ✗ | } | |
| 2757 | } | ||
| 2758 | ✗ | break; | |
| 2759 | |||
| 2760 | case eeMANHAN: | ||
| 2761 | ✗ | new_id &= 0xFFF; | |
| 2762 | |||
| 2763 | ✗ | for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++) | |
| 2764 | { | ||
| 2765 | ✗ | if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i))) | |
| 2766 | { | ||
| 2767 | ✗ | al_trace("Manhandla head %d could not be created!\n",i+1); | |
| 2768 | |||
| 2769 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 2770 | { | ||
| 2771 | ✗ | guys.del(guys.Count()-1); | |
| 2772 | ✗ | } | |
| 2773 | |||
| 2774 | ✗ | return 0; | |
| 2775 | } | ||
| 2776 | |||
| 2777 | |||
| 2778 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1; | |
| 2779 | ✗ | } | |
| 2780 | |||
| 2781 | ✗ | break; | |
| 2782 | |||
| 2783 | case eeGLEEOK: | ||
| 2784 | { | ||
| 2785 | /* | ||
| 2786 | new_id &= 0xFFF; | ||
| 2787 | int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)); | ||
| 2788 | Z_scripterrlog("Gleeok head count is %d\n",head_cnt); | ||
| 2789 | for(int32_t i=0; i<head_cnt; i++) | ||
| 2790 | { | ||
| 2791 | //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok); | ||
| 2792 | if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok))) | ||
| 2793 | { | ||
| 2794 | al_trace("Gleeok head %d could not be created!\n",i+1); | ||
| 2795 | |||
| 2796 | for(int32_t j=0; j<i+1; j++) | ||
| 2797 | { | ||
| 2798 | guys.del(guys.Count()-1); | ||
| 2799 | } | ||
| 2800 | |||
| 2801 | break; | ||
| 2802 | } | ||
| 2803 | |||
| 2804 | c-=guysbuf[new_id].misc4; | ||
| 2805 | */ | ||
| 2806 | |||
| 2807 | // } | ||
| 2808 | } | ||
| 2809 | ✗ | break; | |
| 2810 | |||
| 2811 | |||
| 2812 | case eePATRA: | ||
| 2813 | { | ||
| 2814 | ✗ | new_id &= 0xFFF; | |
| 2815 | ✗ | int32_t outeyes = 0; | |
| 2816 | ✗ | ptra = new ePatraBS((zfix)x,(zfix)y,id,clk); | |
| 2817 | |||
| 2818 | ✗ | for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++) | |
| 2819 | { | ||
| 2820 | ✗ | if(!((guysbuf[new_id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))) | |
| 2821 | { | ||
| 2822 | ✗ | al_trace("Patra outer eye %d could not be created!\n",i+1); | |
| 2823 | |||
| 2824 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 2825 | ✗ | guys.del(guys.Count()-1); | |
| 2826 | |||
| 2827 | ✗ | return 0; | |
| 2828 | } | ||
| 2829 | else | ||
| 2830 | ✗ | outeyes++; | |
| 2831 | |||
| 2832 | |||
| 2833 | ✗ | } | |
| 2834 | |||
| 2835 | ✗ | for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++) | |
| 2836 | { | ||
| 2837 | ✗ | if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))) | |
| 2838 | { | ||
| 2839 | ✗ | al_trace("Patra inner eye %d could not be created!\n",i+1); | |
| 2840 | |||
| 2841 | ✗ | for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++) | |
| 2842 | ✗ | guys.del(guys.Count()-1); | |
| 2843 | |||
| 2844 | ✗ | return 0; | |
| 2845 | } | ||
| 2846 | |||
| 2847 | |||
| 2848 | ✗ | } | |
| 2849 | ✗ | delete ptra; | |
| 2850 | ✗ | break; | |
| 2851 | } | ||
| 2852 | } | ||
| 2853 | |||
| 2854 | |||
| 2855 | |||
| 2856 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true; | |
| 2857 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer; | |
| 2858 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir; | |
| 2859 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale; | |
| 2860 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular; | |
| 2861 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle; | |
| 2862 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation; | |
| 2863 | //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core. | ||
| 2864 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy; | |
| 2865 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader; | |
| 2866 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer; | |
| 2867 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned; | |
| 2868 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID; | |
| 2869 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->sclk = 0; | |
| 2870 | |||
| 2871 | |||
| 2872 | ✗ | item_set = 0; //Do not make a drop. | |
| 2873 | |||
| 2874 | ✗ | switch(effect_type) | |
| 2875 | { | ||
| 2876 | case -7: | ||
| 2877 | { | ||
| 2878 | ✗ | weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0); | |
| 2879 | ✗ | Lwpns.add(w); | |
| 2880 | ✗ | break; | |
| 2881 | } | ||
| 2882 | case -6: | ||
| 2883 | { | ||
| 2884 | ✗ | weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0); | |
| 2885 | ✗ | Lwpns.add(w); | |
| 2886 | ✗ | break; | |
| 2887 | } | ||
| 2888 | case -5: | ||
| 2889 | { | ||
| 2890 | ✗ | weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz); | |
| 2891 | ✗ | Lwpns.add(w); | |
| 2892 | ✗ | break; | |
| 2893 | } | ||
| 2894 | case -4: | ||
| 2895 | { | ||
| 2896 | ✗ | weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz); | |
| 2897 | ✗ | Lwpns.add(w); | |
| 2898 | ✗ | break; | |
| 2899 | } | ||
| 2900 | ✗ | case -3: explode(1); break; | |
| 2901 | ✗ | case -2: explode(2); break; | |
| 2902 | ✗ | case -1: explode(0); break; | |
| 2903 | ✗ | case 0: break; | |
| 2904 | |||
| 2905 | default: | ||
| 2906 | { | ||
| 2907 | //Dummy weapon function | ||
| 2908 | ✗ | if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID. | |
| 2909 | ✗ | weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0); | |
| 2910 | ✗ | Lwpns.add(w); | |
| 2911 | ✗ | break; | |
| 2912 | } | ||
| 2913 | } | ||
| 2914 | |||
| 2915 | |||
| 2916 | ✗ | yofs = -32768; | |
| 2917 | ✗ | switch(guysbuf[new_id&0xFFF].family) | |
| 2918 | { | ||
| 2919 | case eeGLEEOK: | ||
| 2920 | { | ||
| 2921 | ✗ | Z_scripterrlog("Replacing a gleeok.\n"); | |
| 2922 | ✗ | enemy *tempenemy = (enemy *) guys.getByUID(parentCore); | |
| 2923 | ✗ | hp = -999; | |
| 2924 | ✗ | tempenemy->hp = -999; | |
| 2925 | ✗ | break; | |
| 2926 | |||
| 2927 | } | ||
| 2928 | default: | ||
| 2929 | ✗ | hp = -1000; break; | |
| 2930 | } | ||
| 2931 | ✗ | ++game->guys[(currmap*MAPSCRSNORMAL)+currscr]; | |
| 2932 | ✗ | return 1; | |
| 2933 | |||
| 2934 | } | ||
| 2935 | case edSPLIT: | ||
| 2936 | { | ||
| 2937 | //int32_t ex = x; int32_t ey = y; | ||
| 2938 | //al_trace("edSplit dmisc3: %d\n", dmisc3); | ||
| 2939 | //al_trace("edSplit dmisc4: %d\n", dmisc4); | ||
| 2940 | /* | ||
| 2941 | if ( txsx > 1 ) | ||
| 2942 | { | ||
| 2943 | ex += ( txsz-1 ) * 8; //from its middle | ||
| 2944 | } | ||
| 2945 | if ( tysx > 1 ) | ||
| 2946 | { | ||
| 2947 | ey += ( tysz-1 ) * 8; //from its middle | ||
| 2948 | } | ||
| 2949 | */ | ||
| 2950 | ✗ | for ( int32_t q = 0; q < dmisc4; q++ ) | |
| 2951 | { | ||
| 2952 | |||
| 2953 | //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15); | ||
| 2954 | ✗ | addenemy( | |
| 2955 | //ex,ey, | ||
| 2956 | ✗ | x,y, | |
| 2957 | ✗ | dmisc3+0x1000,-15); | |
| 2958 | //addenemy(ex,ey,dmisc3,0); | ||
| 2959 | |||
| 2960 | ✗ | } | |
| 2961 | ✗ | item_set = 0; //Do not make a drop. | |
| 2962 | ✗ | hp = -1000; | |
| 2963 | ✗ | return -1; | |
| 2964 | |||
| 2965 | } | ||
| 2966 | case edSUMMON: | ||
| 2967 | { | ||
| 2968 | |||
| 2969 | |||
| 2970 | //al_trace("edSplit dmisc3: %d\n", dmisc3); | ||
| 2971 | //al_trace("edSplit dmisc4: %d\n", dmisc4); | ||
| 2972 | ✗ | int32_t summon_count = (zc_oldrand()%dmisc4)+1; | |
| 2973 | ✗ | for ( int32_t q = 0; q < summon_count; q++ ) | |
| 2974 | { | ||
| 2975 | ✗ | int32_t x2=16*((zc_oldrand()%12)+2); | |
| 2976 | ✗ | int32_t y2=16*((zc_oldrand()%7)+2); | |
| 2977 | ✗ | addenemy( | |
| 2978 | //(x+(txsz*16)/2),(y+(tysz*16)/2) | ||
| 2979 | ✗ | x2,y2, | |
| 2980 | ✗ | dmisc3+0x1000,-15); | |
| 2981 | //addenemy(ex,ey,dmisc3,0); | ||
| 2982 | |||
| 2983 | ✗ | } | |
| 2984 | ✗ | sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x))); | |
| 2985 | ✗ | return -1; | |
| 2986 | |||
| 2987 | } | ||
| 2988 | |||
| 2989 | case edEXPLODESMALL: | ||
| 2990 | { | ||
| 2991 | ✗ | weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false); | |
| 2992 | ✗ | Ewpns.add(ew); | |
| 2993 | ✗ | item_set = 0; //Should we make a drop? | |
| 2994 | ✗ | hp = -1000; | |
| 2995 | ✗ | return -1; | |
| 2996 | } | ||
| 2997 | |||
| 2998 | |||
| 2999 | case edEXPLODEHARMLESS: | ||
| 3000 | { | ||
| 3001 | ✗ | weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false); | |
| 3002 | ✗ | Ewpns.add(ew); | |
| 3003 | ✗ | ew->hyofs = -32768; | |
| 3004 | ✗ | item_set = 0; //Should we make a drop? | |
| 3005 | ✗ | hp = -1000; | |
| 3006 | ✗ | return -1; | |
| 3007 | } | ||
| 3008 | |||
| 3009 | |||
| 3010 | case edEXPLODELARGE: | ||
| 3011 | { | ||
| 3012 | ✗ | weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false); | |
| 3013 | ✗ | Ewpns.add(ew); | |
| 3014 | |||
| 3015 | ✗ | hp = -1000; | |
| 3016 | ✗ | return -1; | |
| 3017 | } | ||
| 3018 | |||
| 3019 | |||
| 3020 | case edTRIGGERSECRETS: | ||
| 3021 | { | ||
| 3022 | ✗ | hidden_entrance(0, true, false, -4); | |
| 3023 | ✗ | return -1; | |
| 3024 | } | ||
| 3025 | |||
| 3026 | case edSTUNORCHINK: | ||
| 3027 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
22 | if (stunclk && get_qr(qr_NO_STUNLOCK)) |
| 3028 | { | ||
| 3029 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3030 | ✗ | return 1; | |
| 3031 | } | ||
| 3032 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 times.
|
21 | else if(*power <= 0) |
| 3033 | { | ||
| 3034 | //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK"); | ||
| 3035 | 20 | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3036 | 20 | return 1; | |
| 3037 | } | ||
| 3038 | [[fallthrough]]; | ||
| 3039 | |||
| 3040 | case edSTUNORIGNORE: | ||
| 3041 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2 | if (stunclk && get_qr(qr_NO_STUNLOCK)) |
| 3042 | { | ||
| 3043 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3044 | ✗ | return 1; | |
| 3045 | } | ||
| 3046 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | else if(*power <= 0) |
| 3047 | ✗ | return 0; | |
| 3048 | [[fallthrough]]; | ||
| 3049 | |||
| 3050 | case edSTUNONLY: | ||
| 3051 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
1 | if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159) |
| 3052 | { | ||
| 3053 | //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId); | ||
| 3054 | // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId); | ||
| 3055 | ✗ | return 1; | |
| 3056 | } | ||
| 3057 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if (stunclk && get_qr(qr_NO_STUNLOCK)) |
| 3058 | { | ||
| 3059 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3060 | ✗ | return 1; | |
| 3061 | } | ||
| 3062 | else | ||
| 3063 | { | ||
| 3064 | 1 | stunclk=160; | |
| 3065 | 1 | sfx(WAV_EHIT,pan(int32_t(x))); | |
| 3066 | |||
| 3067 | 1 | return 1; | |
| 3068 | } | ||
| 3069 | |||
| 3070 | case edCHINKL1: | ||
| 3071 | ✗ | if(*power >= 1*game->get_hero_dmgmult()) break; | |
| 3072 | [[fallthrough]]; | ||
| 3073 | case edCHINKL2: | ||
| 3074 | ✗ | if(*power >= 2*game->get_hero_dmgmult()) break; | |
| 3075 | [[fallthrough]]; | ||
| 3076 | case edCHINKL4: | ||
| 3077 | ✗ | if(*power >= 4*game->get_hero_dmgmult()) break; | |
| 3078 | [[fallthrough]]; | ||
| 3079 | case edCHINKL6: | ||
| 3080 | ✗ | if(*power >= 6*game->get_hero_dmgmult()) break; | |
| 3081 | [[fallthrough]]; | ||
| 3082 | case edCHINKL8: | ||
| 3083 | ✗ | if(*power >= 8*game->get_hero_dmgmult()) break; | |
| 3084 | [[fallthrough]]; | ||
| 3085 | case edCHINKL10: | ||
| 3086 | ✗ | if(*power >= 10*game->get_hero_dmgmult()) break; | |
| 3087 | [[fallthrough]]; | ||
| 3088 | case edCHINK: | ||
| 3089 | //al_trace("defendNew() is at: %s\n", "returning edCHINK"); | ||
| 3090 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3091 | ✗ | return 1; | |
| 3092 | |||
| 3093 | case edIGNOREL1: | ||
| 3094 | ✗ | if(*power > 0) break; | |
| 3095 | [[fallthrough]]; | ||
| 3096 | |||
| 3097 | case edIGNORE: | ||
| 3098 | 331 | return 0; | |
| 3099 | |||
| 3100 | case ed1HKO: | ||
| 3101 | 32 | *power = hp; | |
| 3102 | 32 | return -2; | |
| 3103 | |||
| 3104 | case ed2x: | ||
| 3105 | { | ||
| 3106 | ✗ | *power = zc_max(1,*power*2); | |
| 3107 | //int32_t pow = *power; | ||
| 3108 | //*power = vbound((pow*2),0,214747); | ||
| 3109 | ✗ | return -1; | |
| 3110 | } | ||
| 3111 | case ed3x: | ||
| 3112 | { | ||
| 3113 | ✗ | *power = zc_max(1,*power*3); | |
| 3114 | //int32_t pow = *power; | ||
| 3115 | //*power = vbound((pow*3),0,214747); | ||
| 3116 | ✗ | return -1; | |
| 3117 | } | ||
| 3118 | |||
| 3119 | case ed4x: | ||
| 3120 | { | ||
| 3121 | ✗ | *power = zc_max(1,*power*4); | |
| 3122 | //int32_t pow = *power; | ||
| 3123 | //*power = vbound((pow*4),0,214747); | ||
| 3124 | ✗ | return -1; | |
| 3125 | } | ||
| 3126 | |||
| 3127 | |||
| 3128 | case edHEAL: | ||
| 3129 | { //Probably needs its own function, or routine in the damage functuon to heal if power is negative. | ||
| 3130 | //int32_t pow = *power; | ||
| 3131 | //*power = vbound((pow*-1),0,214747); | ||
| 3132 | //break; | ||
| 3133 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
|
79 | *power = zc_min(0,*power*-1); |
| 3134 | 79 | return -1; | |
| 3135 | } | ||
| 3136 | /* | ||
| 3137 | case edLEVELDAMAGE: | ||
| 3138 | { | ||
| 3139 | int32_t pow = *power; | ||
| 3140 | int32_t lvl = *level; | ||
| 3141 | *power = vbound((pow*lvl),0,214747); | ||
| 3142 | break; | ||
| 3143 | } | ||
| 3144 | case edLEVELREDUCTION: | ||
| 3145 | { | ||
| 3146 | int32_t pow = *power; | ||
| 3147 | int32_t lvl = *level; | ||
| 3148 | *power = vbound((pow/lvl),0,214747); | ||
| 3149 | break; | ||
| 3150 | } | ||
| 3151 | */ | ||
| 3152 | |||
| 3153 | case edQUARTDAMAGE: | ||
| 3154 | ✗ | *power = zc_max(1,*power/2); | |
| 3155 | |||
| 3156 | [[fallthrough]]; | ||
| 3157 | case edHALFDAMAGE: | ||
| 3158 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | *power = zc_max(1,*power/2); |
| 3159 | 2 | break; | |
| 3160 | |||
| 3161 | case edSWITCH: | ||
| 3162 | { | ||
| 3163 | ✗ | if(Hero.switchhookclk) return 0; //Already switching! | |
| 3164 | ✗ | switch(family) | |
| 3165 | { | ||
| 3166 | case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK: | ||
| 3167 | case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON: | ||
| 3168 | ✗ | return 0; | |
| 3169 | } | ||
| 3170 | ✗ | hooked_combopos = -1; | |
| 3171 | ✗ | hooked_layerbits = 0; | |
| 3172 | ✗ | switching_object = this; | |
| 3173 | ✗ | switch_hooked = true; | |
| 3174 | ✗ | Hero.doSwitchHook(game->get_switchhookstyle()); | |
| 3175 | ✗ | if(QMisc.miscsfx[sfxSWITCHED]) | |
| 3176 | ✗ | sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x)); | |
| 3177 | ✗ | return 1; | |
| 3178 | } | ||
| 3179 | |||
| 3180 | case 0: | ||
| 3181 | { | ||
| 3182 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
|
2181 | if(edef == edefSwitchHook) |
| 3183 | ✗ | return -1; | |
| 3184 |
6/6✓ Branch 0 taken 317 times.
✓ Branch 1 taken 1864 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 288 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
|
2181 | if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0) |
| 3185 | { | ||
| 3186 | 13 | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3187 | 13 | return 1; | |
| 3188 | } | ||
| 3189 | |||
| 3190 | } | ||
| 3191 | 2168 | } | |
| 3192 | |||
| 3193 | 2170 | return -1; | |
| 3194 | 2758 | } | |
| 3195 | |||
| 3196 | 2758 | int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w) | |
| 3197 | { | ||
| 3198 |
1/2✓ Branch 0 taken 2758 times.
✗ Branch 1 not taken.
|
2758 | int wuid = w?w->getUID():0; |
| 3199 |
1/2✓ Branch 0 taken 2758 times.
✗ Branch 1 not taken.
|
2758 | bool fakeweap = (w && !Lwpns.getByUID(wuid)); |
| 3200 | |||
| 3201 |
1/2✓ Branch 0 taken 2758 times.
✗ Branch 1 not taken.
|
2758 | if(fakeweap) |
| 3202 | ✗ | Lwpns.add(w); | |
| 3203 | 2758 | std::vector<int32_t> &ev = FFCore.eventData; | |
| 3204 | 2758 | ev.clear(); | |
| 3205 | 2758 | ev.push_back(*power*10000); | |
| 3206 | 2758 | ev.push_back(edef*10000); | |
| 3207 | 2758 | ev.push_back(unblockable*10000); | |
| 3208 | 2758 | ev.push_back(wpnId*10000); | |
| 3209 | 2758 | ev.push_back(0); | |
| 3210 | 2758 | ev.push_back(getUID()); | |
| 3211 | 2758 | ev.push_back(wuid); | |
| 3212 | |||
| 3213 | 2758 | throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1); | |
| 3214 | 2758 | *power = ev[0]/10000; | |
| 3215 | 2758 | edef = ev[1]/10000; | |
| 3216 | 2758 | unblockable = byte(ev[2]/10000); | |
| 3217 | 2758 | wpnId = ev[3] / 10000; | |
| 3218 | 2758 | bool nullify = ev[4]!=0; | |
| 3219 | 2758 | ev.clear(); | |
| 3220 | 2758 | int ret = 0; | |
| 3221 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2758 times.
|
2758 | if(!nullify) |
| 3222 | { | ||
| 3223 | 2758 | ret = defendNew(wpnId, power, edef, unblockable); | |
| 3224 |
2/2✓ Branch 0 taken 509 times.
✓ Branch 1 taken 2249 times.
|
2758 | if(ret == -1) |
| 3225 | { | ||
| 3226 | 2249 | ev.push_back(*power*10000); | |
| 3227 | 2249 | ev.push_back(edef*10000); | |
| 3228 | 2249 | ev.push_back(unblockable*10000); | |
| 3229 | 2249 | ev.push_back(wpnId*10000); | |
| 3230 | 2249 | ev.push_back(0); | |
| 3231 | 2249 | ev.push_back(getUID()); | |
| 3232 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2249 times.
|
2249 | ev.push_back(w?w->getUID():0); |
| 3233 | |||
| 3234 | 2249 | throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2); | |
| 3235 | 2249 | *power = ev[0]/10000; | |
| 3236 | 2249 | nullify = ev[4]!=0; | |
| 3237 | 2249 | ev.clear(); | |
| 3238 | 2249 | } | |
| 3239 | 2758 | } | |
| 3240 |
1/2✓ Branch 0 taken 2758 times.
✗ Branch 1 not taken.
|
2758 | if(fakeweap) |
| 3241 | ✗ | Lwpns.remove(w); | |
| 3242 | |||
| 3243 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2758 times.
|
2758 | return nullify ? 0 : ret; |
| 3244 | } | ||
| 3245 | |||
| 3246 | 2352 | int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap) | |
| 3247 | { | ||
| 3248 |
2/2✓ Branch 0 taken 2344 times.
✓ Branch 1 taken 8 times.
|
2352 | if(!realweap) realweap = w; |
| 3249 | 2352 | int32_t wid = getWeaponID(w); | |
| 3250 | |||
| 3251 | 2352 | int32_t edef = resolveEnemyDefence(w); | |
| 3252 |
2/2✓ Branch 0 taken 1802 times.
✓ Branch 1 taken 550 times.
|
2352 | if(QHeader.zelda_version > 0x250) |
| 3253 | 1802 | return defendNewInt(wid, power, edef, w->unblockable, realweap); | |
| 3254 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
✗ Branch 2 not taken.
|
550 | switch(wid) |
| 3255 | { | ||
| 3256 | case wScript1: case wScript2: case wScript3: case wScript4: case wScript5: | ||
| 3257 | case wScript6: case wScript7: case wScript8: case wScript9: case wScript10: | ||
| 3258 | ✗ | return defend(wpnId, power, edefSCRIPT); | |
| 3259 | |||
| 3260 | case wWhistle: | ||
| 3261 | ✗ | return -1; | |
| 3262 | |||
| 3263 | default: | ||
| 3264 | 550 | return defendNewInt(wid, power, edef, w->unblockable, realweap); | |
| 3265 | } | ||
| 3266 | 2352 | } | |
| 3267 | |||
| 3268 | |||
| 3269 | // Check defenses without actually acting on them. | ||
| 3270 | ✗ | bool enemy::candamage(int32_t power, int32_t edef, byte unblockable) | |
| 3271 | { | ||
| 3272 | ✗ | switch(defense[edef]) | |
| 3273 | { | ||
| 3274 | case edSTUNONLY: | ||
| 3275 | ✗ | return false; | |
| 3276 | case edSTUNORCHINK: | ||
| 3277 | case edCHINK: | ||
| 3278 | ✗ | return unblockable&WPNUNB_BLOCK; | |
| 3279 | case edSTUNORIGNORE: | ||
| 3280 | case edIGNORE: | ||
| 3281 | ✗ | return unblockable&WPNUNB_IGNR; | |
| 3282 | |||
| 3283 | case edIGNOREL1: | ||
| 3284 | ✗ | return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult(); | |
| 3285 | case edCHINKL1: | ||
| 3286 | ✗ | return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult(); | |
| 3287 | |||
| 3288 | case edCHINKL2: | ||
| 3289 | ✗ | return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult(); | |
| 3290 | |||
| 3291 | case edCHINKL4: | ||
| 3292 | ✗ | return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult(); | |
| 3293 | |||
| 3294 | case edCHINKL6: | ||
| 3295 | ✗ | return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult(); | |
| 3296 | |||
| 3297 | case edCHINKL8: | ||
| 3298 | ✗ | return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult(); | |
| 3299 | } | ||
| 3300 | |||
| 3301 | ✗ | return true; | |
| 3302 | ✗ | } | |
| 3303 | |||
| 3304 | // Do we do damage? | ||
| 3305 | // 0: takehit returns 0 | ||
| 3306 | // 1: takehit returns 1 | ||
| 3307 | // -1: do damage | ||
| 3308 | ✗ | int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef) | |
| 3309 | { | ||
| 3310 | ✗ | if(shieldCanBlock) | |
| 3311 | { | ||
| 3312 | ✗ | switch(defense[edef]) | |
| 3313 | { | ||
| 3314 | case edIGNORE: | ||
| 3315 | ✗ | return 0; | |
| 3316 | case edIGNOREL1: | ||
| 3317 | case edSTUNORIGNORE: | ||
| 3318 | ✗ | if(*power <= 0) | |
| 3319 | ✗ | return 0; | |
| 3320 | ✗ | } | |
| 3321 | |||
| 3322 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3323 | ✗ | return 1; | |
| 3324 | } | ||
| 3325 | |||
| 3326 | ✗ | switch(defense[edef]) | |
| 3327 | { | ||
| 3328 | case edSTUNORCHINK: | ||
| 3329 | ✗ | if(*power <= 0) | |
| 3330 | { | ||
| 3331 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3332 | ✗ | return 1; | |
| 3333 | } | ||
| 3334 | |||
| 3335 | [[fallthrough]]; | ||
| 3336 | case edSTUNORIGNORE: | ||
| 3337 | ✗ | if(*power <= 0) | |
| 3338 | ✗ | return 0; | |
| 3339 | |||
| 3340 | [[fallthrough]]; | ||
| 3341 | case edSTUNONLY: | ||
| 3342 | ✗ | if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159) | |
| 3343 | ✗ | return 1; | |
| 3344 | |||
| 3345 | ✗ | stunclk=160; | |
| 3346 | ✗ | sfx(WAV_EHIT,pan(int32_t(x))); | |
| 3347 | ✗ | return 1; | |
| 3348 | |||
| 3349 | case edFREEZE: | ||
| 3350 | ✗ | frozenclock=-1; | |
| 3351 | //sfx(WAV_FREEZE,pan(int32_t(x))); | ||
| 3352 | ✗ | return 1; | |
| 3353 | |||
| 3354 | case edCHINKL1: | ||
| 3355 | ✗ | if(*power >= 1*game->get_hero_dmgmult()) break; | |
| 3356 | [[fallthrough]]; | ||
| 3357 | case edCHINKL2: | ||
| 3358 | ✗ | if(*power >= 2*game->get_hero_dmgmult()) break; | |
| 3359 | [[fallthrough]]; | ||
| 3360 | case edCHINKL4: | ||
| 3361 | ✗ | if(*power >= 4*game->get_hero_dmgmult()) break; | |
| 3362 | [[fallthrough]]; | ||
| 3363 | case edCHINKL6: | ||
| 3364 | ✗ | if(*power >= 6*game->get_hero_dmgmult()) break; | |
| 3365 | [[fallthrough]]; | ||
| 3366 | case edCHINKL8: | ||
| 3367 | ✗ | if(*power >= 8*game->get_hero_dmgmult()) break; | |
| 3368 | [[fallthrough]]; | ||
| 3369 | case edCHINKL10: | ||
| 3370 | ✗ | if(*power >= 10*game->get_hero_dmgmult()) break; | |
| 3371 | [[fallthrough]]; | ||
| 3372 | case edCHINK: | ||
| 3373 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3374 | ✗ | return 1; | |
| 3375 | case edTRIGGERSECRETS: | ||
| 3376 | ✗ | hidden_entrance(0, true, false, -4); | |
| 3377 | ✗ | break; | |
| 3378 | |||
| 3379 | case edIGNOREL1: | ||
| 3380 | ✗ | if(*power > 0) break; | |
| 3381 | [[fallthrough]]; | ||
| 3382 | case edIGNORE: | ||
| 3383 | ✗ | return 0; | |
| 3384 | |||
| 3385 | case ed1HKO: | ||
| 3386 | ✗ | *power = hp; | |
| 3387 | ✗ | return -2; | |
| 3388 | |||
| 3389 | case ed2x: | ||
| 3390 | { | ||
| 3391 | ✗ | *power = zc_max(1,*power*2); | |
| 3392 | //int32_t pow = *power; | ||
| 3393 | //*power = vbound((pow*2),0,214747); | ||
| 3394 | ✗ | return -1; | |
| 3395 | } | ||
| 3396 | case ed3x: | ||
| 3397 | { | ||
| 3398 | ✗ | *power = zc_max(1,*power*3); | |
| 3399 | //int32_t pow = *power; | ||
| 3400 | //*power = vbound((pow*3),0,214747); | ||
| 3401 | ✗ | return -1; | |
| 3402 | } | ||
| 3403 | |||
| 3404 | case ed4x: | ||
| 3405 | { | ||
| 3406 | ✗ | *power = zc_max(1,*power*4); | |
| 3407 | //int32_t pow = *power; | ||
| 3408 | //*power = vbound((pow*4),0,214747); | ||
| 3409 | ✗ | return -1; | |
| 3410 | } | ||
| 3411 | |||
| 3412 | |||
| 3413 | case edHEAL: | ||
| 3414 | { //Probably needs its own function, or routine in the damage functuon to heal if power is negative. | ||
| 3415 | //int32_t pow = *power; | ||
| 3416 | //*power = vbound((pow*-1),0,214747); | ||
| 3417 | //break; | ||
| 3418 | ✗ | *power = zc_min(0,*power*-1); | |
| 3419 | ✗ | return -1; | |
| 3420 | } | ||
| 3421 | /* | ||
| 3422 | case edLEVELDAMAGE: | ||
| 3423 | { | ||
| 3424 | int32_t pow = *power; | ||
| 3425 | int32_t lvl = *level; | ||
| 3426 | *power = vbound((pow*lvl),0,214747); | ||
| 3427 | break; | ||
| 3428 | } | ||
| 3429 | case edLEVELREDUCTION: | ||
| 3430 | { | ||
| 3431 | int32_t pow = *power; | ||
| 3432 | int32_t lvl = *level; | ||
| 3433 | *power = vbound((pow/lvl),0,214747); | ||
| 3434 | break; | ||
| 3435 | } | ||
| 3436 | */ | ||
| 3437 | |||
| 3438 | |||
| 3439 | case edQUARTDAMAGE: | ||
| 3440 | ✗ | *power = zc_max(1,*power/2); | |
| 3441 | |||
| 3442 | [[fallthrough]]; | ||
| 3443 | case edHALFDAMAGE: | ||
| 3444 | ✗ | *power = zc_max(1,*power/2); | |
| 3445 | ✗ | break; | |
| 3446 | } | ||
| 3447 | |||
| 3448 | ✗ | return -1; | |
| 3449 | ✗ | } | |
| 3450 | |||
| 3451 | // Defend against a particular item class. | ||
| 3452 | ✗ | int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power) | |
| 3453 | { | ||
| 3454 | ✗ | int32_t def=-1; | |
| 3455 | |||
| 3456 | ✗ | switch(wpnId) | |
| 3457 | { | ||
| 3458 | // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these. | ||
| 3459 | case wBrang: | ||
| 3460 | ✗ | def = defend(wpnId, power, edefBRANG); | |
| 3461 | ✗ | break; | |
| 3462 | |||
| 3463 | case wHookshot: | ||
| 3464 | ✗ | def = defend(wpnId, power, edefHOOKSHOT); | |
| 3465 | ✗ | break; | |
| 3466 | |||
| 3467 | // Anyway... | ||
| 3468 | case wBomb: | ||
| 3469 | ✗ | def = defend(wpnId, power, edefBOMB); | |
| 3470 | ✗ | break; | |
| 3471 | |||
| 3472 | case wSBomb: | ||
| 3473 | ✗ | def = defend(wpnId, power, edefSBOMB); | |
| 3474 | ✗ | break; | |
| 3475 | |||
| 3476 | case wArrow: | ||
| 3477 | ✗ | def = defend(wpnId, power, edefARROW); | |
| 3478 | ✗ | break; | |
| 3479 | |||
| 3480 | case wFire: | ||
| 3481 | ✗ | def = defend(wpnId, power, edefFIRE); | |
| 3482 | ✗ | break; | |
| 3483 | |||
| 3484 | case wWand: | ||
| 3485 | ✗ | def = defend(wpnId, power, edefWAND); | |
| 3486 | ✗ | break; | |
| 3487 | |||
| 3488 | case wMagic: | ||
| 3489 | ✗ | def = defend(wpnId, power, edefMAGIC); | |
| 3490 | ✗ | break; | |
| 3491 | |||
| 3492 | case wHammer: | ||
| 3493 | ✗ | def = defend(wpnId, power, edefHAMMER); | |
| 3494 | ✗ | break; | |
| 3495 | |||
| 3496 | case wSword: | ||
| 3497 | ✗ | def = defend(wpnId, power, edefSWORD); | |
| 3498 | ✗ | break; | |
| 3499 | |||
| 3500 | case wBeam: | ||
| 3501 | ✗ | def = defend(wpnId, power, edefBEAM); | |
| 3502 | ✗ | break; | |
| 3503 | |||
| 3504 | case wRefBeam: | ||
| 3505 | ✗ | def = defend(wpnId, power, edefREFBEAM); | |
| 3506 | ✗ | break; | |
| 3507 | |||
| 3508 | case wRefMagic: | ||
| 3509 | ✗ | def = defend(wpnId, power, edefREFMAGIC); | |
| 3510 | ✗ | break; | |
| 3511 | |||
| 3512 | case wRefFireball: | ||
| 3513 | ✗ | def = defend(wpnId, power, edefREFBALL); | |
| 3514 | ✗ | break; | |
| 3515 | |||
| 3516 | case wRefRock: | ||
| 3517 | ✗ | def = defend(wpnId, power, edefREFROCK); | |
| 3518 | ✗ | break; | |
| 3519 | |||
| 3520 | case wStomp: | ||
| 3521 | ✗ | def = defend(wpnId, power, edefSTOMP); | |
| 3522 | ✗ | break; | |
| 3523 | |||
| 3524 | case wCByrna: | ||
| 3525 | ✗ | def = defend(wpnId, power, edefBYRNA); | |
| 3526 | ✗ | break; | |
| 3527 | |||
| 3528 | case wScript1: | ||
| 3529 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01); | |
| 3530 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3531 | ✗ | break; | |
| 3532 | |||
| 3533 | case wScript2: | ||
| 3534 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02); | |
| 3535 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3536 | ✗ | break; | |
| 3537 | |||
| 3538 | case wScript3: | ||
| 3539 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03); | |
| 3540 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3541 | ✗ | break; | |
| 3542 | |||
| 3543 | case wScript4: | ||
| 3544 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04); | |
| 3545 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3546 | ✗ | break; | |
| 3547 | |||
| 3548 | case wScript5: | ||
| 3549 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05); | |
| 3550 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3551 | ✗ | break; | |
| 3552 | |||
| 3553 | case wScript6: | ||
| 3554 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06); | |
| 3555 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3556 | ✗ | break; | |
| 3557 | |||
| 3558 | case wScript7: | ||
| 3559 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07); | |
| 3560 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3561 | ✗ | break; | |
| 3562 | |||
| 3563 | case wScript8: | ||
| 3564 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08); | |
| 3565 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3566 | ✗ | break; | |
| 3567 | |||
| 3568 | case wScript9: | ||
| 3569 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09); | |
| 3570 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3571 | ✗ | break; | |
| 3572 | |||
| 3573 | case wScript10: | ||
| 3574 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10); | |
| 3575 | ✗ | else def = defend(wpnId, power, edefSCRIPT); | |
| 3576 | ✗ | break; | |
| 3577 | |||
| 3578 | case wWhistle: | ||
| 3579 | ✗ | if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle); | |
| 3580 | ✗ | else break; | |
| 3581 | ✗ | break; | |
| 3582 | |||
| 3583 | case wRefArrow: | ||
| 3584 | ✗ | def = defend(wpnId, power, edefREFARROW); | |
| 3585 | ✗ | break; | |
| 3586 | case wRefFire: | ||
| 3587 | ✗ | def = defend(wpnId, power, edefREFFIRE); | |
| 3588 | ✗ | break; | |
| 3589 | case wRefFire2: | ||
| 3590 | ✗ | def = defend(wpnId, power, edefREFFIRE2); | |
| 3591 | ✗ | break; | |
| 3592 | |||
| 3593 | //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break. | ||
| 3594 | //Probably best to do this from the qest file, loading the values of Script(generic) into each | ||
| 3595 | //of the ten if the quest version is lower than N. | ||
| 3596 | //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour. | ||
| 3597 | //such as bool UseSeparatedScriptDefences. hah. | ||
| 3598 | default: | ||
| 3599 | //if(wpnId>=wScript1 && wpnId<=wScript10) | ||
| 3600 | // { | ||
| 3601 | // def = defend(wpnId, power, edefSCRIPT); | ||
| 3602 | // } | ||
| 3603 | // } | ||
| 3604 | |||
| 3605 | ✗ | break; | |
| 3606 | } | ||
| 3607 | |||
| 3608 | ✗ | return def; | |
| 3609 | } | ||
| 3610 | |||
| 3611 | // take damage or ignore it | ||
| 3612 | // -1: damage (if any) dealt | ||
| 3613 | // 1: blocked | ||
| 3614 | // 0: weapon passes through unhindered | ||
| 3615 | 3775 | int32_t enemy::takehit(weapon *w, weapon* realweap) | |
| 3616 | { | ||
| 3617 |
2/4✓ Branch 0 taken 3775 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3775 times.
|
3775 | if(fallclk||drownclk) return 0; |
| 3618 |
2/2✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 2199 times.
|
3775 | if(!realweap) realweap = w; |
| 3619 | 3775 | int32_t wpnId = w->id; | |
| 3620 | 3775 | int32_t power = w->power; | |
| 3621 | 3775 | int32_t wpnx = w->x; | |
| 3622 | 3775 | int32_t wpny = w->y; | |
| 3623 | 3775 | int32_t enemyHitWeapon = w->parentitem; | |
| 3624 | int32_t wpnDir; | ||
| 3625 | 3775 | int32_t parent_item = w->parentitem; | |
| 3626 | |||
| 3627 |
1/2✓ Branch 0 taken 3775 times.
✗ Branch 1 not taken.
|
3775 | if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ ) |
| 3628 | { | ||
| 3629 | ✗ | wpnId = w->useweapon; | |
| 3630 | ✗ | } | |
| 3631 | |||
| 3632 | // If it's a boomerang that just bounced, use the opposite direction; | ||
| 3633 | // otherwise, it might bypass a shield. This probably won't handle | ||
| 3634 | // every case correctly, but it's better than having shields simply | ||
| 3635 | // not work against boomerangs. | ||
| 3636 |
8/8✓ Branch 0 taken 406 times.
✓ Branch 1 taken 3369 times.
✓ Branch 2 taken 245 times.
✓ Branch 3 taken 161 times.
✓ Branch 4 taken 224 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 44 times.
✓ Branch 7 taken 180 times.
|
3775 | if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264) |
| 3637 | 180 | wpnDir = oppositeDir[w->dir]; | |
| 3638 | else | ||
| 3639 | 3595 | wpnDir = w->dir; | |
| 3640 | |||
| 3641 |
5/8✓ Branch 0 taken 3775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3775 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3775 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 3768 times.
|
3775 | if(dying || clk<0 || hclk>0 || superman) |
| 3642 | 7 | return 0; | |
| 3643 | |||
| 3644 | //Prevent boomerang from writing to hitby[] for more than one frame. | ||
| 3645 | //This also prevents stunlock. | ||
| 3646 | //if ( stunclk > 0 ) return 0; | ||
| 3647 | //this needs a rule for boomerangs that cannot stunlock! | ||
| 3648 | //further, bouncing weapons should probably SFX_CHINK and bounce here. | ||
| 3649 | //sigh. | ||
| 3650 | |||
| 3651 | 3768 | int32_t ret = -1; | |
| 3652 | |||
| 3653 | // This obscure quest rule... | ||
| 3654 |
5/6✓ Branch 0 taken 1441 times.
✓ Branch 1 taken 2327 times.
✓ Branch 2 taken 1440 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1440 times.
|
3768 | if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb)) |
| 3655 | { | ||
| 3656 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 3657 | 1 | double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx)); | |
| 3658 | 1 | wpnDir=zc_oldrand()&3; | |
| 3659 | |||
| 3660 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4))) |
| 3661 | { | ||
| 3662 | ✗ | wpnDir=down; | |
| 3663 | ✗ | } | |
| 3664 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4))) |
| 3665 | { | ||
| 3666 | 1 | wpnDir=right; | |
| 3667 | 1 | } | |
| 3668 | ✗ | else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4))) | |
| 3669 | { | ||
| 3670 | ✗ | wpnDir=up; | |
| 3671 | ✗ | } | |
| 3672 | else | ||
| 3673 | { | ||
| 3674 | ✗ | wpnDir=left; | |
| 3675 | } | ||
| 3676 | 1 | } | |
| 3677 | |||
| 3678 | 3768 | int32_t xdir = dir; | |
| 3679 | 3768 | shieldCanBlock=false; | |
| 3680 | |||
| 3681 | //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down; | ||
| 3682 |
2/4✓ Branch 0 taken 3768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3768 times.
|
3768 | if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir)) |
| 3683 |
7/10✓ Branch 0 taken 275 times.
✓ Branch 1 taken 275 times.
✓ Branch 2 taken 561 times.
✓ Branch 3 taken 3482 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3482 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3482 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3482 times.
|
3768 | || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right)))) |
| 3684 | ) | ||
| 3685 | // The hammer should already be dealt with by subclasses (Walker etc.) | ||
| 3686 | { | ||
| 3687 |
5/10✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 104 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
836 | switch(wpnId) |
| 3688 | { | ||
| 3689 | // Weapons which shields protect against | ||
| 3690 | case wSword: | ||
| 3691 | case wWand: | ||
| 3692 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
|
104 | if(Hero.getCharging()>0) |
| 3693 | ✗ | Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging | |
| 3694 | |||
| 3695 | [[fallthrough]]; | ||
| 3696 | case wHookshot: | ||
| 3697 | case wHSHandle: | ||
| 3698 | case wBrang: | ||
| 3699 | 104 | shieldCanBlock=true; | |
| 3700 | 109 | break; | |
| 3701 | |||
| 3702 | case wBeam: | ||
| 3703 | case wRefBeam: | ||
| 3704 | // Mirror shielded enemies! | ||
| 3705 | #if 0 | ||
| 3706 | if(false /*flags2&guy_mirror*/ && !get_qr(qr_SWORDMIRROR)) | ||
| 3707 | { | ||
| 3708 | if(wpnId>wEnemyWeapons) | ||
| 3709 | return 0; | ||
| 3710 | |||
| 3711 | sfx(WAV_CHINK,pan(int32_t(x))); | ||
| 3712 | return 1; | ||
| 3713 | } | ||
| 3714 | |||
| 3715 | #endif | ||
| 3716 | |||
| 3717 | [[fallthrough]]; | ||
| 3718 | case wRefRock: | ||
| 3719 | case wRefFireball: | ||
| 3720 | case wMagic: | ||
| 3721 | #if 0 | ||
| 3722 | if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS))) | ||
| 3723 | { | ||
| 3724 | sfx(WAV_CHINK,pan(int32_t(x))); | ||
| 3725 | return 3; | ||
| 3726 | } | ||
| 3727 | |||
| 3728 | #endif | ||
| 3729 | |||
| 3730 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | if(wpnId>wEnemyWeapons) |
| 3731 | ✗ | return 0; | |
| 3732 | |||
| 3733 | [[fallthrough]]; | ||
| 3734 | case wArrow: | ||
| 3735 | 6 | case wRefArrow: | |
| 3736 | default: | ||
| 3737 | 6 | shieldCanBlock=true; | |
| 3738 | 6 | break; | |
| 3739 | |||
| 3740 | // Bombs | ||
| 3741 | case wSBomb: | ||
| 3742 | case wBomb: | ||
| 3743 | ✗ | if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock; | |
| 3744 | ✗ | else if (!get_qr(qr_BOMBSPIERCESHIELD)) | |
| 3745 | { | ||
| 3746 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 3747 | ✗ | return 0; | |
| 3748 | } | ||
| 3749 | ✗ | else break; | |
| 3750 | |||
| 3751 | // Weapons which ignore shields | ||
| 3752 | case wWhistle: | ||
| 3753 | case wHammer: | ||
| 3754 | ✗ | break; | |
| 3755 | |||
| 3756 | // Weapons which shouldn't be removed by shields | ||
| 3757 | case wLitBomb: | ||
| 3758 | case wLitSBomb: | ||
| 3759 | case wWind: | ||
| 3760 | case wPhantom: | ||
| 3761 | case wSSparkle: | ||
| 3762 | case wBait: | ||
| 3763 | 69 | return 0; | |
| 3764 | |||
| 3765 | case wFire: | ||
| 3766 | case wRefFire: | ||
| 3767 | case wRefFire2: | ||
| 3768 | ; | ||
| 3769 | 107 | } | |
| 3770 | 217 | } | |
| 3771 | |||
| 3772 |
4/8✓ Branch 0 taken 942 times.
✓ Branch 1 taken 2344 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 406 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
3699 | switch(wpnId) |
| 3773 | { | ||
| 3774 | case wWhistle: //No longer completely ignore whistle weapons! -Z | ||
| 3775 | { | ||
| 3776 | |||
| 3777 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted |
| 3778 | { | ||
| 3779 | //al_trace("Whistle weapon in %s\n", "takehit flag == 0"); | ||
| 3780 | 7 | return 0; break; | |
| 3781 | } | ||
| 3782 | else | ||
| 3783 | { | ||
| 3784 | ✗ | w->power = power = itemsbuf[parent_item].misc5; | |
| 3785 | |||
| 3786 | ✗ | int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap); | |
| 3787 | |||
| 3788 | ✗ | if(def <= 0) | |
| 3789 | { | ||
| 3790 | ✗ | if ( def == -2 ) hp -= hp; | |
| 3791 | ✗ | else hp -= power; | |
| 3792 | ✗ | return def; | |
| 3793 | } | ||
| 3794 | ✗ | break; | |
| 3795 | } | ||
| 3796 | break; | ||
| 3797 | } | ||
| 3798 | |||
| 3799 | case wPhantom: | ||
| 3800 | ✗ | return 0; | |
| 3801 | |||
| 3802 | case wLitBomb: | ||
| 3803 | case wLitSBomb: | ||
| 3804 | case wBait: | ||
| 3805 | case wWind: | ||
| 3806 | case wSSparkle: | ||
| 3807 | 942 | return 0; | |
| 3808 | |||
| 3809 | case wFSparkle: | ||
| 3810 | |||
| 3811 | // Only take sparkle damage if the sparkle's parent item is not | ||
| 3812 | // defended against. | ||
| 3813 | ✗ | if(enemyHitWeapon > -1) | |
| 3814 | { | ||
| 3815 | ✗ | int32_t p = 0; | |
| 3816 | ✗ | int32_t f = itemsbuf[enemyHitWeapon].family; | |
| 3817 | |||
| 3818 | ✗ | switch(f) | |
| 3819 | { | ||
| 3820 | case itype_arrow: | ||
| 3821 | ✗ | if(!candamage(p, edefARROW, w->unblockable)) return 0; | |
| 3822 | |||
| 3823 | ✗ | break; | |
| 3824 | |||
| 3825 | case itype_cbyrna: | ||
| 3826 | ✗ | if(!candamage(p, edefBYRNA, w->unblockable)) return 0; | |
| 3827 | |||
| 3828 | ✗ | break; | |
| 3829 | |||
| 3830 | case itype_brang: | ||
| 3831 | ✗ | if(!candamage(p, edefBRANG, w->unblockable)) return 0; | |
| 3832 | |||
| 3833 | ✗ | break; | |
| 3834 | |||
| 3835 | default: | ||
| 3836 | ✗ | return 0; | |
| 3837 | } | ||
| 3838 | ✗ | } | |
| 3839 | |||
| 3840 | ✗ | wpnId = wSword; | |
| 3841 | ✗ | power = game->get_hero_dmgmult()>>1; | |
| 3842 | ✗ | goto fsparkle; | |
| 3843 | break; | ||
| 3844 | |||
| 3845 | case wBrang: | ||
| 3846 | { | ||
| 3847 | //int32_t def = defendNew(wpnId, &power, edefBRANG, w); | ||
| 3848 | 406 | int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap); | |
| 3849 | //preventing stunlock might be best, here. -Z | ||
| 3850 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 372 times.
|
406 | if(def >= 0) return def; |
| 3851 | |||
| 3852 | // Not hurt by 0-damage weapons | ||
| 3853 |
2/2✓ Branch 0 taken 61 times.
✓ Branch 1 taken 311 times.
|
372 | if(!(flags & guy_bhit)) |
| 3854 | { | ||
| 3855 | 311 | stunclk=160; | |
| 3856 | |||
| 3857 |
2/4✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 311 times.
|
311 | if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang)) |
| 3858 | { | ||
| 3859 | ✗ | hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult(); | |
| 3860 | ✗ | goto hitclock; | |
| 3861 | } | ||
| 3862 | |||
| 3863 | 311 | break; | |
| 3864 | } | ||
| 3865 | |||
| 3866 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
|
61 | if(!power) |
| 3867 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
|
61 | hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult(); |
| 3868 | else | ||
| 3869 | ✗ | hp-=power; | |
| 3870 | |||
| 3871 | 61 | goto hitclock; | |
| 3872 | } | ||
| 3873 | |||
| 3874 | case wHookshot: | ||
| 3875 | { | ||
| 3876 | //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w); | ||
| 3877 | ✗ | int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap); | |
| 3878 | |||
| 3879 | ✗ | if(def >= 0) return def; | |
| 3880 | |||
| 3881 | ✗ | bool swgrab = switch_hooked || w->family_class == itype_switchhook; | |
| 3882 | ✗ | if(swgrab || !(flags & guy_bhit)) | |
| 3883 | { | ||
| 3884 | ✗ | if(!swgrab) | |
| 3885 | ✗ | stunclk=160; | |
| 3886 | |||
| 3887 | ✗ | if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) | |
| 3888 | { | ||
| 3889 | ✗ | hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult(); | |
| 3890 | ✗ | goto hitclock; | |
| 3891 | } | ||
| 3892 | |||
| 3893 | ✗ | break; | |
| 3894 | } | ||
| 3895 | |||
| 3896 | ✗ | if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult(); | |
| 3897 | else | ||
| 3898 | ✗ | hp-=power; | |
| 3899 | |||
| 3900 | ✗ | goto hitclock; | |
| 3901 | } | ||
| 3902 | break; | ||
| 3903 | |||
| 3904 | case wHSHandle: | ||
| 3905 | { | ||
| 3906 | ✗ | if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1) | |
| 3907 | ✗ | return 0; | |
| 3908 | |||
| 3909 | ✗ | bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE) | |
| 3910 | ✗ | && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0)); | |
| 3911 | |||
| 3912 | // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas | ||
| 3913 | ✗ | if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot) | |
| 3914 | ✗ | || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right)))) | |
| 3915 | ✗ | return 0; | |
| 3916 | |||
| 3917 | ✗ | power = game->get_hero_dmgmult(); | |
| 3918 | ✗ | } | |
| 3919 | |||
| 3920 | fsparkle: | ||
| 3921 | |||
| 3922 | [[fallthrough]]; | ||
| 3923 | default: | ||
| 3924 | // Work out the defenses! | ||
| 3925 | { | ||
| 3926 | 2344 | int32_t def = defenditemclassNew(wpnId, &power, w, realweap); | |
| 3927 | |||
| 3928 |
2/2✓ Branch 0 taken 441 times.
✓ Branch 1 taken 1903 times.
|
2344 | if(def >= 0) |
| 3929 | 441 | return def; | |
| 3930 |
2/2✓ Branch 0 taken 1871 times.
✓ Branch 1 taken 32 times.
|
1903 | else if(def == -2) |
| 3931 | { | ||
| 3932 | 32 | ret = 0; | |
| 3933 | 32 | } | |
| 3934 | } | ||
| 3935 | |||
| 3936 |
1/2✓ Branch 0 taken 1903 times.
✗ Branch 1 not taken.
|
3806 | if(!power) |
| 3937 | { | ||
| 3938 | ✗ | if(flags & guy_bhit) | |
| 3939 | ✗ | hp-=1; | |
| 3940 | else | ||
| 3941 | { | ||
| 3942 | // Don't make a long chain of 'stun' hits | ||
| 3943 | ✗ | if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0) | |
| 3944 | ✗ | return 1; | |
| 3945 | |||
| 3946 | |||
| 3947 | ✗ | if(!switch_hooked) | |
| 3948 | ✗ | stunclk=160; | |
| 3949 | ✗ | break; | |
| 3950 | } | ||
| 3951 | ✗ | } | |
| 3952 | 1903 | else hp-=power; | |
| 3953 | |||
| 3954 | hitclock: | ||
| 3955 | 1964 | hclk=33; | |
| 3956 | |||
| 3957 | // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way | ||
| 3958 |
2/2✓ Branch 0 taken 867 times.
✓ Branch 1 taken 1097 times.
|
1964 | if((dir&2)==(w->dir&2)) |
| 3959 | { | ||
| 3960 | 1097 | sclk=(w->dir<<8)+16; | |
| 3961 | 1097 | } | |
| 3962 | 1964 | } | |
| 3963 | |||
| 3964 |
5/6✓ Branch 0 taken 1903 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 119 times.
✓ Branch 3 taken 2156 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 119 times.
|
2275 | if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal)) |
| 3965 | { | ||
| 3966 | 119 | fading=fade_blue_poof; | |
| 3967 | 119 | } | |
| 3968 | |||
| 3969 |
6/6✓ Branch 0 taken 742 times.
✓ Branch 1 taken 1533 times.
✓ Branch 2 taken 642 times.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 209 times.
✓ Branch 5 taken 433 times.
|
2275 | if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later |
| 3970 | { | ||
| 3971 |
1/2✓ Branch 0 taken 1742 times.
✗ Branch 1 not taken.
|
1742 | if( hitsfx > 0 ) //user-set hit sound. |
| 3972 | { | ||
| 3973 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1742 times.
|
1742 | if (!dying) //don't play the hit sound on death! -Z |
| 3974 | 1742 | sfx(hitsfx, pan(int32_t(x))); | |
| 3975 | 1742 | } | |
| 3976 | ✗ | else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one. | |
| 3977 | 1742 | } | |
| 3978 | else //2.50.2 or earlier | ||
| 3979 | { | ||
| 3980 | 533 | sfx(WAV_EHIT, pan(int32_t(x))); | |
| 3981 | 533 | sfx(hitsfx, pan(int32_t(x))); | |
| 3982 | } | ||
| 3983 |
2/2✓ Branch 0 taken 2272 times.
✓ Branch 1 taken 3 times.
|
2275 | if(family==eeGUY) |
| 3984 | 3 | sfx(WAV_EDEAD, pan(int32_t(x))); | |
| 3985 | |||
| 3986 | // Penetrating weapons | ||
| 3987 |
4/4✓ Branch 0 taken 2255 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 1914 times.
✓ Branch 3 taken 361 times.
|
2275 | if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate()) |
| 3988 | { | ||
| 3989 | 361 | int32_t item=enemyHitWeapon; | |
| 3990 | |||
| 3991 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 349 times.
|
361 | if(wpnId==wArrow) |
| 3992 | { | ||
| 3993 | //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class. | ||
| 3994 |
2/6✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
12 | if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow)) |
| 3995 | ✗ | return 0; | |
| 3996 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0; |
| 3997 | //if(item<0) | ||
| 3998 | else | ||
| 3999 | 12 | item=current_item_id(itype_arrow); | |
| 4000 | 12 | } | |
| 4001 | |||
| 4002 | else | ||
| 4003 | { | ||
| 4004 | |||
| 4005 | //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class. | ||
| 4006 |
2/6✓ Branch 0 taken 349 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 349 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
349 | if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword)) |
| 4007 | ✗ | return 0; | |
| 4008 | |||
| 4009 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 349 times.
|
349 | else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0; |
| 4010 | else | ||
| 4011 | //if(item<0) | ||
| 4012 | 349 | item=current_item_id(itype_sword); | |
| 4013 | } | ||
| 4014 | 361 | } | |
| 4015 | |||
| 4016 | 2275 | return ret; | |
| 4017 | 3775 | } | |
| 4018 | |||
| 4019 | 1081639 | bool enemy::dont_draw() | |
| 4020 | { | ||
| 4021 |
5/6✓ Branch 0 taken 1079992 times.
✓ Branch 1 taken 1647 times.
✓ Branch 2 taken 1079992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 781 times.
✓ Branch 5 taken 1079211 times.
|
1081639 | if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1))) |
| 4022 | 2428 | return true; | |
| 4023 | |||
| 4024 |
2/2✓ Branch 0 taken 1469 times.
✓ Branch 1 taken 1077742 times.
|
1079211 | if(flags&guy_invisible) |
| 4025 | 1469 | return true; | |
| 4026 | |||
| 4027 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1077742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1077742 | if(flags&lens_only && !lensclk) |
| 4028 | ✗ | return true; | |
| 4029 | |||
| 4030 | 1077742 | return false; | |
| 4031 | 1081639 | } | |
| 4032 | |||
| 4033 | #define DRAW_NORMAL 2 | ||
| 4034 | #define DRAW_CLOAKED 1 | ||
| 4035 | #define DRAW_INVIS 0 | ||
| 4036 | // base drawing function to be used by all derived classes instead of | ||
| 4037 | // sprite::draw() | ||
| 4038 | 962096 | void enemy::draw(BITMAP *dest) | |
| 4039 | { | ||
| 4040 | 962096 | didScriptThisFrame = false; //Since there's no better place to put it | |
| 4041 |
5/6✓ Branch 0 taken 954775 times.
✓ Branch 1 taken 7321 times.
✓ Branch 2 taken 954775 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3482 times.
✓ Branch 5 taken 951293 times.
|
962096 | if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1))) |
| 4042 | 10803 | return; | |
| 4043 |
2/2✓ Branch 0 taken 34797 times.
✓ Branch 1 taken 916496 times.
|
951293 | if(flags&guy_invisible) |
| 4044 | 34797 | return; | |
| 4045 | |||
| 4046 | //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies | ||
| 4047 | // be cloaked if they have "invisible displays as cloaked" checked. | ||
| 4048 | |||
| 4049 | 916496 | byte canSee = DRAW_NORMAL; | |
| 4050 | //Enemy specific stuff | ||
| 4051 |
1/2✓ Branch 0 taken 916496 times.
✗ Branch 1 not taken.
|
916496 | if ( editorflags & ENEMY_FLAG1 ) |
| 4052 | { | ||
| 4053 | ✗ | canSee = DRAW_INVIS; | |
| 4054 | ✗ | if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED; | |
| 4055 | ✗ | if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2)) | |
| 4056 | { | ||
| 4057 | ✗ | if (game->item[dmisc13]) | |
| 4058 | { | ||
| 4059 | ✗ | canSee = DRAW_NORMAL; | |
| 4060 | ✗ | } | |
| 4061 | //else if ( lensclk && getlensid.flags SHOWINVIS ) | ||
| 4062 | //{ | ||
| 4063 | // | ||
| 4064 | //} | ||
| 4065 | //else | ||
| 4066 | //{ | ||
| 4067 | // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED; | ||
| 4068 | // //otherwisem invisible | ||
| 4069 | //} | ||
| 4070 | ✗ | } | |
| 4071 | ✗ | } | |
| 4072 | //Room specific | ||
| 4073 |
2/2✓ Branch 0 taken 914160 times.
✓ Branch 1 taken 2336 times.
|
916496 | if (tmpscr->flags3&fINVISROOM) |
| 4074 | { | ||
| 4075 |
4/6✓ Branch 0 taken 2336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 2281 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
|
2391 | if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) && |
| 4076 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
|
55 | !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED; |
| 4077 | 2336 | } | |
| 4078 | //Lens check | ||
| 4079 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 916496 times.
|
916496 | if (lensclk) |
| 4080 | { | ||
| 4081 | ✗ | if(flags&lens_only) | |
| 4082 | { | ||
| 4083 | ✗ | if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL; | |
| 4084 | ✗ | } | |
| 4085 | ✗ | } | |
| 4086 | else | ||
| 4087 | { | ||
| 4088 |
1/2✓ Branch 0 taken 916496 times.
✗ Branch 1 not taken.
|
916496 | if(flags&lens_only) |
| 4089 | ✗ | canSee = DRAW_INVIS; | |
| 4090 | } | ||
| 4091 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 916496 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
916496 | if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED; |
| 4092 |
3/4✓ Branch 0 taken 916441 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 916441 times.
✗ Branch 3 not taken.
|
916496 | if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED; |
| 4093 | |||
| 4094 |
1/2✓ Branch 0 taken 916496 times.
✗ Branch 1 not taken.
|
916496 | if (canSee == DRAW_INVIS) |
| 4095 | ✗ | return; | |
| 4096 | |||
| 4097 |
3/4✓ Branch 0 taken 916354 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 916354 times.
|
916496 | if(fallclk||drownclk) |
| 4098 | { | ||
| 4099 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
|
142 | if (canSee == DRAW_CLOAKED) |
| 4100 | { | ||
| 4101 | ✗ | sprite::drawcloaked(dest); | |
| 4102 | ✗ | } | |
| 4103 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
|
142 | else if (canSee == DRAW_NORMAL) |
| 4104 | { | ||
| 4105 | 142 | sprite::draw(dest); | |
| 4106 | 142 | } | |
| 4107 | 142 | return; | |
| 4108 | } | ||
| 4109 | 916354 | int32_t cshold=cs; | |
| 4110 | |||
| 4111 |
2/2✓ Branch 0 taken 25890 times.
✓ Branch 1 taken 890464 times.
|
916354 | if(dying) |
| 4112 | { | ||
| 4113 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 25890 times.
|
25890 | if(clk2>=19) |
| 4114 | { | ||
| 4115 | ✗ | if(!(clk2&2)) | |
| 4116 | { | ||
| 4117 | //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it. | ||
| 4118 | ✗ | if (canSee == DRAW_CLOAKED) | |
| 4119 | { | ||
| 4120 | ✗ | sprite::drawcloaked(dest); | |
| 4121 | ✗ | } | |
| 4122 | ✗ | else if (canSee == DRAW_NORMAL) | |
| 4123 | { | ||
| 4124 | ✗ | sprite::draw(dest); | |
| 4125 | ✗ | } | |
| 4126 | ✗ | } | |
| 4127 | ✗ | return; | |
| 4128 | } | ||
| 4129 | |||
| 4130 | 25890 | flip = 0; | |
| 4131 | 25890 | tile = wpnsbuf[spr_death].tile; | |
| 4132 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 25890 times.
|
25890 | if ( do_animation ) |
| 4133 | { | ||
| 4134 | 25890 | int32_t offs = 0; | |
| 4135 |
2/2✓ Branch 0 taken 23494 times.
✓ Branch 1 taken 2396 times.
|
25890 | if(!get_qr(qr_HARDCODED_ENEMY_ANIMS)) |
| 4136 | { | ||
| 4137 |
2/2✓ Branch 0 taken 2310 times.
✓ Branch 1 taken 86 times.
|
2396 | if(clk2 > 2) |
| 4138 | { | ||
| 4139 | 86 | spr_death_anim_clk=0; | |
| 4140 | 86 | clk2=1; | |
| 4141 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 85 times.
|
86 | if(hp > -1000) |
| 4142 | 85 | death_sfx(); | |
| 4143 | 86 | } | |
| 4144 |
4/4✓ Branch 0 taken 2120 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 2108 times.
|
2396 | if(clk2==1 && spr_death_anim_clk>-1) |
| 4145 | { | ||
| 4146 | 2108 | ++clk2; | |
| 4147 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2108 times.
|
2108 | spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1)); |
| 4148 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2108 times.
|
2108 | spr_death_anim_frm *= zc_max(1,txsz); |
| 4149 | 2108 | int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile); | |
| 4150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2108 times.
|
2108 | spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows); |
| 4151 |
4/6✗ Branch 0 not taken.
✓ Branch 1 taken 2108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2108 times.
✓ Branch 4 taken 2022 times.
✓ Branch 5 taken 86 times.
|
2108 | if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1))) |
| 4152 | { | ||
| 4153 | 86 | spr_death_anim_clk=-1; | |
| 4154 | 86 | clk2=1; | |
| 4155 | 86 | } | |
| 4156 | 2108 | } | |
| 4157 | 2396 | tile += spr_death_anim_frm; | |
| 4158 | 2396 | } | |
| 4159 |
2/2✓ Branch 0 taken 1108 times.
✓ Branch 1 taken 22386 times.
|
23494 | else if(BSZ) |
| 4160 | { | ||
| 4161 |
2/2✓ Branch 0 taken 871 times.
✓ Branch 1 taken 237 times.
|
1108 | offs = zc_min((15-clk2)/3,4); |
| 4162 | 1108 | } | |
| 4163 |
4/4✓ Branch 0 taken 14947 times.
✓ Branch 1 taken 7439 times.
✓ Branch 2 taken 7495 times.
✓ Branch 3 taken 7452 times.
|
22386 | else if(clk2>6 && clk2<=12) |
| 4164 | { | ||
| 4165 | 7452 | offs = 1; | |
| 4166 | 7452 | } | |
| 4167 | |||
| 4168 |
2/2✓ Branch 0 taken 17490 times.
✓ Branch 1 taken 8400 times.
|
25890 | if(offs) |
| 4169 | { | ||
| 4170 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8400 times.
|
8400 | offs *= zc_max(1,txsz); |
| 4171 | 8400 | int32_t rows = TILEROW(tile+offs)-TILEROW(tile); | |
| 4172 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8400 times.
|
8400 | offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows); |
| 4173 | 8400 | } | |
| 4174 | 25890 | tile += offs; | |
| 4175 | 25890 | } | |
| 4176 | |||
| 4177 |
6/6✓ Branch 0 taken 23494 times.
✓ Branch 1 taken 2396 times.
✓ Branch 2 taken 22386 times.
✓ Branch 3 taken 1108 times.
✓ Branch 4 taken 1620 times.
✓ Branch 5 taken 20766 times.
|
25890 | if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof) |
| 4178 | 5124 | cs = wpnsbuf[spr_death].csets&15; | |
| 4179 | else | ||
| 4180 | 20766 | cs = (((clk2+5)>>1)&3)+6; | |
| 4181 | 25890 | } | |
| 4182 |
3/4✓ Branch 0 taken 26581 times.
✓ Branch 1 taken 863883 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26581 times.
|
890464 | else if(hclk>0 && getCanFlicker()) |
| 4183 | { | ||
| 4184 | 26581 | cs = getFlashingCSet(); | |
| 4185 | 26581 | } | |
| 4186 | //draw every other frame for flickering enemies | ||
| 4187 |
2/2✓ Branch 0 taken 575 times.
✓ Branch 1 taken 915779 times.
|
916354 | if (is_hitflickerframe(false)) |
| 4188 | { | ||
| 4189 |
4/6✓ Branch 0 taken 312 times.
✓ Branch 1 taken 263 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 312 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 263 times.
|
575 | int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0; |
| 4190 |
2/4✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 575 times.
|
575 | if (game->get_spriteflickercolor() || temp_flicker_color) |
| 4191 | { | ||
| 4192 | ✗ | sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp); | |
| 4193 | ✗ | sprite_flicker_color = temp_flicker_color; | |
| 4194 | ✗ | sprite::draw(dest); | |
| 4195 | ✗ | } | |
| 4196 | 575 | } | |
| 4197 | else | ||
| 4198 | { | ||
| 4199 |
2/2✓ Branch 0 taken 55 times.
✓ Branch 1 taken 915724 times.
|
915779 | if (canSee == DRAW_CLOAKED) |
| 4200 | { | ||
| 4201 | 55 | sprite::drawcloaked(dest); | |
| 4202 | 55 | } | |
| 4203 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 915724 times.
|
915724 | else if (canSee == DRAW_NORMAL) |
| 4204 | { | ||
| 4205 |
1/2✓ Branch 0 taken 915724 times.
✗ Branch 1 not taken.
|
915724 | if ( frozenclock < 0 ) |
| 4206 | { | ||
| 4207 | ✗ | if ( frozentile > 0 ) tile = frozentile; | |
| 4208 | ✗ | loadpalset(csBOSS,frozencset); | |
| 4209 | ✗ | } | |
| 4210 | 915724 | sprite::draw(dest); | |
| 4211 | 915724 | } | |
| 4212 | } | ||
| 4213 | 916354 | cs=cshold; | |
| 4214 | 962096 | } | |
| 4215 | |||
| 4216 | //old zc bosses | ||
| 4217 | 919820 | void enemy::drawzcboss(BITMAP *dest) | |
| 4218 | { | ||
| 4219 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 919820 times.
|
919820 | if(dont_draw()) |
| 4220 | ✗ | return; | |
| 4221 | |||
| 4222 | 919820 | int32_t cshold=cs; | |
| 4223 | |||
| 4224 |
2/2✓ Branch 0 taken 25436 times.
✓ Branch 1 taken 894384 times.
|
919820 | if(dying) |
| 4225 | { | ||
| 4226 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 25436 times.
|
25436 | if(clk2>=19) |
| 4227 | { | ||
| 4228 | ✗ | if(!(clk2&2)) | |
| 4229 | ✗ | sprite::drawzcboss(dest); | |
| 4230 | |||
| 4231 | ✗ | return; | |
| 4232 | } | ||
| 4233 | |||
| 4234 | 25436 | flip = 0; | |
| 4235 | 25436 | tile = wpnsbuf[spr_death].tile; | |
| 4236 | |||
| 4237 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 25436 times.
|
25436 | if ( do_animation ) |
| 4238 | { | ||
| 4239 |
2/2✓ Branch 0 taken 23250 times.
✓ Branch 1 taken 2186 times.
|
25436 | if(!get_qr(qr_HARDCODED_ENEMY_ANIMS)) |
| 4240 | { | ||
| 4241 |
2/2✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
|
2186 | if(clk2 > 2) |
| 4242 | { | ||
| 4243 | 2 | spr_death_anim_clk=0; | |
| 4244 | 2 | clk2=1; | |
| 4245 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(hp > -1000) |
| 4246 | 2 | death_sfx(); | |
| 4247 | 2 | } | |
| 4248 |
4/4✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
|
2186 | if(clk2==1 && spr_death_anim_clk>-1) |
| 4249 | { | ||
| 4250 | 2 | ++clk2; | |
| 4251 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1)); |
| 4252 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | spr_death_anim_frm *= zc_max(1,txsz); |
| 4253 | 2 | int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile); | |
| 4254 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows); |
| 4255 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1))) |
| 4256 | { | ||
| 4257 | ✗ | spr_death_anim_clk=-1; | |
| 4258 | ✗ | clk2=1; | |
| 4259 | ✗ | } | |
| 4260 | 2 | } | |
| 4261 | 2186 | tile += spr_death_anim_frm; | |
| 4262 | 2186 | } | |
| 4263 |
2/2✓ Branch 0 taken 1017 times.
✓ Branch 1 taken 22233 times.
|
23250 | else if(BSZ) |
| 4264 |
2/2✓ Branch 0 taken 795 times.
✓ Branch 1 taken 222 times.
|
1017 | tile += zc_min((15-clk2)/3,4); |
| 4265 |
4/4✓ Branch 0 taken 14845 times.
✓ Branch 1 taken 7388 times.
✓ Branch 2 taken 7444 times.
✓ Branch 3 taken 7401 times.
|
22233 | else if(clk2>6 && clk2<=12) |
| 4266 | 7401 | ++tile; | |
| 4267 | 25436 | } | |
| 4268 | |||
| 4269 |
6/6✓ Branch 0 taken 23250 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 22233 times.
✓ Branch 3 taken 1017 times.
✓ Branch 4 taken 1620 times.
✓ Branch 5 taken 20613 times.
|
25436 | if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof) |
| 4270 | 4823 | cs = wpnsbuf[spr_death].csets&15; | |
| 4271 | else | ||
| 4272 | 20613 | cs = (((clk2+5)>>1)&3)+6; | |
| 4273 | 25436 | } | |
| 4274 |
2/2✓ Branch 0 taken 864338 times.
✓ Branch 1 taken 30046 times.
|
894384 | else if(hclk>0) |
| 4275 | { | ||
| 4276 | 30046 | cs = getFlashingCSet(); | |
| 4277 | 30046 | } | |
| 4278 | |||
| 4279 |
2/4✓ Branch 0 taken 2281 times.
✓ Branch 1 taken 917539 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
919820 | if((tmpscr->flags3&fINVISROOM) && |
| 4280 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2281 times.
|
2281 | !(current_item(itype_amulet)) && |
| 4281 | ✗ | !(get_qr(qr_LENSSEESENEMIES) && | |
| 4282 | ✗ | lensclk) && family!=eeGANON) | |
| 4283 | { | ||
| 4284 | ✗ | sprite::drawcloaked(dest); | |
| 4285 | ✗ | } | |
| 4286 | else | ||
| 4287 | { | ||
| 4288 |
2/2✓ Branch 0 taken 132 times.
✓ Branch 1 taken 919688 times.
|
919820 | if (is_hitflickerframe(true)) |
| 4289 | { | ||
| 4290 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
|
132 | int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0; |
| 4291 |
1/2✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
|
132 | if (game->get_spriteflickercolor()) |
| 4292 | { | ||
| 4293 | ✗ | sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp); | |
| 4294 | ✗ | sprite_flicker_color = temp_flicker_color; | |
| 4295 | ✗ | sprite::drawzcboss(dest); | |
| 4296 | ✗ | } | |
| 4297 | 132 | } | |
| 4298 | else | ||
| 4299 | 919688 | sprite::drawzcboss(dest); | |
| 4300 | } | ||
| 4301 | |||
| 4302 | 919820 | cs=cshold; | |
| 4303 | 919820 | } | |
| 4304 | |||
| 4305 | |||
| 4306 | // similar to the overblock function--can do up to a 32x32 sprite | ||
| 4307 | //will this play nicely with scripttile, solely using the modifications in sprite::draw()? | ||
| 4308 | 4056 | void enemy::drawblock(BITMAP *dest,int32_t mask) | |
| 4309 | { | ||
| 4310 | 4056 | int32_t thold=tile; | |
| 4311 | 4056 | int32_t t1=tile; | |
| 4312 | 4056 | int32_t t2=tile+20; | |
| 4313 | 4056 | int32_t t3=tile+1; | |
| 4314 | 4056 | int32_t t4=tile+21; | |
| 4315 | |||
| 4316 |
1/5✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4056 times.
|
4056 | switch(mask) |
| 4317 | { | ||
| 4318 | case 1: | ||
| 4319 | ✗ | enemy::drawzcboss(dest); | |
| 4320 | ✗ | break; | |
| 4321 | |||
| 4322 | case 3: | ||
| 4323 | ✗ | if(flip&2) | |
| 4324 | ✗ | zc_swap(t1,t2); | |
| 4325 | |||
| 4326 | ✗ | tile=t1; | |
| 4327 | ✗ | enemy::drawzcboss(dest); | |
| 4328 | ✗ | tile=t2; | |
| 4329 | ✗ | yofs+=16; | |
| 4330 | ✗ | enemy::drawzcboss(dest); | |
| 4331 | ✗ | yofs-=16; | |
| 4332 | ✗ | break; | |
| 4333 | |||
| 4334 | case 5: | ||
| 4335 | ✗ | t2=tile+1; | |
| 4336 | |||
| 4337 | ✗ | if(flip&1) | |
| 4338 | ✗ | zc_swap(t1,t2); | |
| 4339 | |||
| 4340 | ✗ | tile=t1; | |
| 4341 | ✗ | enemy::drawzcboss(dest); | |
| 4342 | ✗ | tile=t2; | |
| 4343 | ✗ | xofs+=16; | |
| 4344 | ✗ | enemy::drawzcboss(dest); | |
| 4345 | ✗ | xofs-=16; | |
| 4346 | ✗ | break; | |
| 4347 | |||
| 4348 | case 15: | ||
| 4349 |
2/2✓ Branch 0 taken 3881 times.
✓ Branch 1 taken 175 times.
|
4056 | if(flip&1) |
| 4350 | { | ||
| 4351 | 175 | zc_swap(t1,t3); | |
| 4352 | 175 | zc_swap(t2,t4); | |
| 4353 | 175 | } | |
| 4354 | |||
| 4355 |
1/2✓ Branch 0 taken 4056 times.
✗ Branch 1 not taken.
|
4056 | if(flip&2) |
| 4356 | { | ||
| 4357 | ✗ | zc_swap(t1,t2); | |
| 4358 | ✗ | zc_swap(t3,t4); | |
| 4359 | ✗ | } | |
| 4360 | |||
| 4361 | 4056 | tile=t1; | |
| 4362 | 4056 | enemy::drawzcboss(dest); | |
| 4363 | 4056 | tile=t2; | |
| 4364 | 4056 | yofs+=16; | |
| 4365 | 4056 | enemy::drawzcboss(dest); | |
| 4366 | 4056 | yofs-=16; | |
| 4367 | 4056 | tile=t3; | |
| 4368 | 4056 | xofs+=16; | |
| 4369 | 4056 | enemy::drawzcboss(dest); | |
| 4370 | 4056 | tile=t4; | |
| 4371 | 4056 | yofs+=16; | |
| 4372 | 4056 | enemy::drawzcboss(dest); | |
| 4373 | 4056 | xofs-=16; | |
| 4374 | 4056 | yofs-=16; | |
| 4375 | 4056 | break; | |
| 4376 | } | ||
| 4377 | |||
| 4378 | 4056 | tile=thold; | |
| 4379 | 4056 | } | |
| 4380 | |||
| 4381 | 156357 | void enemy::drawshadow(BITMAP *dest, bool translucent) | |
| 4382 | { | ||
| 4383 |
3/4✓ Branch 0 taken 152460 times.
✓ Branch 1 taken 3897 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 152460 times.
|
156357 | if(dont_draw() || isSideViewGravity()) |
| 4384 | { | ||
| 4385 | 3897 | return; | |
| 4386 | } | ||
| 4387 | |||
| 4388 |
2/2✓ Branch 0 taken 3503 times.
✓ Branch 1 taken 148957 times.
|
152460 | if(dying) |
| 4389 | { | ||
| 4390 | 3503 | return; | |
| 4391 | } | ||
| 4392 | |||
| 4393 |
4/4✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 146921 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 148902 times.
|
148957 | if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))|| |
| 4394 | 148957 | (darkroom)) | |
| 4395 | { | ||
| 4396 | 55 | return; | |
| 4397 | } | ||
| 4398 | else | ||
| 4399 | { | ||
| 4400 |
4/4✓ Branch 0 taken 141077 times.
✓ Branch 1 taken 7825 times.
✓ Branch 2 taken 140447 times.
✓ Branch 3 taken 630 times.
|
148902 | if(enemycanfall(id, false) && shadowtile == 0) |
| 4401 | 630 | shadowtile = wpnsbuf[spr_shadow].tile; | |
| 4402 | |||
| 4403 |
5/6✓ Branch 0 taken 147709 times.
✓ Branch 1 taken 1193 times.
✓ Branch 2 taken 147709 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139884 times.
✓ Branch 5 taken 7825 times.
|
148902 | if(z>0 || fakez>0 || !enemycanfall(id, false)) |
| 4404 | { | ||
| 4405 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9018 times.
|
9018 | if(!shadow_overpit(this)) |
| 4406 | 9018 | sprite::drawshadow(dest,translucent); | |
| 4407 | 9018 | } | |
| 4408 | } | ||
| 4409 | 156357 | } | |
| 4410 | |||
| 4411 | 4726 | void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh) | |
| 4412 | { | ||
| 4413 | 4726 | BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh); | |
| 4414 | |||
| 4415 |
1/2✓ Branch 0 taken 4726 times.
✗ Branch 1 not taken.
|
4726 | if(sub!=NULL) |
| 4416 | { | ||
| 4417 | 4726 | xofs-=mx; | |
| 4418 | 4726 | yofs-=my; | |
| 4419 | 4726 | enemy::draw(sub); | |
| 4420 | 4726 | xofs+=mx; | |
| 4421 | 4726 | yofs+=my; | |
| 4422 | 4726 | destroy_bitmap(sub); | |
| 4423 | 4726 | } | |
| 4424 | else | ||
| 4425 | ✗ | enemy::draw(dest); | |
| 4426 | 4726 | } | |
| 4427 | |||
| 4428 | // override hit detection to check for invicibility, stunned, etc | ||
| 4429 | 1978491 | bool enemy::hit() | |
| 4430 | { | ||
| 4431 |
4/4✓ Branch 0 taken 1947690 times.
✓ Branch 1 taken 30801 times.
✓ Branch 2 taken 1916740 times.
✓ Branch 3 taken 30950 times.
|
1978491 | if(dying || hclk>0) return false; |
| 4432 | 1916740 | return sprite::hit(); | |
| 4433 | 1978491 | } | |
| 4434 | 540 | bool enemy::hit(sprite *s) | |
| 4435 | { | ||
| 4436 |
2/4✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 540 times.
✗ Branch 3 not taken.
|
540 | if(!hit() || !s->hit()) return false; |
| 4437 | 540 | return sprite::hit(s); | |
| 4438 | 540 | } | |
| 4439 | |||
| 4440 | 942734 | bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2) | |
| 4441 | { | ||
| 4442 |
2/2✓ Branch 0 taken 108119 times.
✓ Branch 1 taken 834615 times.
|
942734 | if(!hit()) return false; |
| 4443 | 834615 | return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2); | |
| 4444 | 942734 | } | |
| 4445 | ✗ | bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2) | |
| 4446 | { | ||
| 4447 | ✗ | if(!hit()) return false; | |
| 4448 | ✗ | return sprite::hit(tx,ty,txsz2,tysz2); | |
| 4449 | ✗ | } | |
| 4450 | |||
| 4451 | 101030 | bool enemy::hit(weapon *w) | |
| 4452 | { | ||
| 4453 |
2/2✓ Branch 0 taken 7641 times.
✓ Branch 1 taken 93389 times.
|
101030 | if(!hit()) return false; |
| 4454 | |||
| 4455 |
2/2✓ Branch 0 taken 85224 times.
✓ Branch 1 taken 8165 times.
|
93389 | if (replay_version_check(0, 14)) |
| 4456 | { | ||
| 4457 |
4/6✓ Branch 0 taken 80877 times.
✓ Branch 1 taken 4347 times.
✓ Branch 2 taken 80877 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80877 times.
✗ Branch 5 not taken.
|
85224 | if(!w->scriptcoldet || w->fallclk || w->drownclk) |
| 4458 | 4347 | return false; | |
| 4459 | 80877 | return sprite::hit(w); | |
| 4460 | } | ||
| 4461 | 8165 | return w->hit(this); | |
| 4462 | 101030 | } | |
| 4463 | |||
| 4464 | 395775 | bool enemy::can_pitfall(bool checkspawning) | |
| 4465 | { | ||
| 4466 |
4/4✓ Branch 0 taken 395108 times.
✓ Branch 1 taken 667 times.
✓ Branch 2 taken 394865 times.
✓ Branch 3 taken 910 times.
|
395775 | if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn. |
| 4467 |
2/2✓ Branch 0 taken 394359 times.
✓ Branch 1 taken 506 times.
|
394865 | switch(guysbuf[id&0xFFF].family) |
| 4468 | { | ||
| 4469 | case eeAQUA: | ||
| 4470 | case eeDIG: | ||
| 4471 | case eeDONGO: | ||
| 4472 | case eeFAIRY: | ||
| 4473 | case eeGANON: | ||
| 4474 | case eeGHOMA: | ||
| 4475 | case eeGLEEOK: | ||
| 4476 | case eeGUY: | ||
| 4477 | case eeLANM: | ||
| 4478 | case eeMANHAN: | ||
| 4479 | case eeMOLD: | ||
| 4480 | case eeNONE: | ||
| 4481 | case eePATRA: | ||
| 4482 | case eeZORA: | ||
| 4483 | 506 | return false; //Disallowed types | |
| 4484 | default: | ||
| 4485 | 394359 | return true; | |
| 4486 | } | ||
| 4487 | 395775 | } | |
| 4488 | //Handle death | ||
| 4489 | 834286 | void enemy::try_death(bool force_kill) | |
| 4490 | { | ||
| 4491 |
7/8✓ Branch 0 taken 834200 times.
✓ Branch 1 taken 86 times.
✓ Branch 2 taken 834198 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1198 times.
✓ Branch 5 taken 833000 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1198 times.
|
834286 | if(!dying && (force_kill || (hp<=0 && !immortal))) |
| 4492 | { | ||
| 4493 | 1200 | std::vector<int32_t> &ev = FFCore.eventData; | |
| 4494 | 1200 | ev.clear(); | |
| 4495 | 1200 | ev.push_back(10000); | |
| 4496 | 1200 | ev.push_back(getUID()); | |
| 4497 | |||
| 4498 | 1200 | throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH); | |
| 4499 | 1200 | bool isSaved = !ev[0]; | |
| 4500 | 1200 | ev.clear(); | |
| 4501 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1200 times.
|
1200 | if(isSaved) return; |
| 4502 | |||
| 4503 |
3/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1192 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
|
1200 | if(itemguy && (hasitem&2)!=0) |
| 4504 | { | ||
| 4505 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
|
17 | for(int32_t i=0; i<items.Count(); i++) |
| 4506 | { | ||
| 4507 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
|
9 | if(((item*)items.spr(i))->pickup&ipENEMY) |
| 4508 | { | ||
| 4509 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if (!get_qr(qr_BROKEN_ITEM_CARRYING)) |
| 4510 | { | ||
| 4511 | ✗ | if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS)) | |
| 4512 | { | ||
| 4513 | ✗ | items.spr(i)->x = x+hxofs+(hit_width/2)-8; | |
| 4514 | ✗ | items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez; | |
| 4515 | ✗ | } | |
| 4516 | else | ||
| 4517 | { | ||
| 4518 | ✗ | if(extend >= 3) | |
| 4519 | { | ||
| 4520 | ✗ | items.spr(i)->x = x+(txsz-1)*8; | |
| 4521 | ✗ | items.spr(i)->y = y-2+(tysz-1)*8; | |
| 4522 | ✗ | } | |
| 4523 | else | ||
| 4524 | { | ||
| 4525 | ✗ | items.spr(i)->x = x; | |
| 4526 | ✗ | items.spr(i)->y = y - 2; | |
| 4527 | } | ||
| 4528 | } | ||
| 4529 | ✗ | items.spr(i)->z = z; | |
| 4530 | ✗ | items.spr(i)->fakez = fakez; | |
| 4531 | ✗ | } | |
| 4532 | else | ||
| 4533 | { | ||
| 4534 | 8 | items.spr(i)->x = x; | |
| 4535 | 8 | items.spr(i)->y = y - 2; | |
| 4536 | } | ||
| 4537 | 8 | } | |
| 4538 | 9 | } | |
| 4539 | 8 | } | |
| 4540 | |||
| 4541 | 1200 | dying=true; | |
| 4542 | |||
| 4543 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1200 times.
|
1200 | if(fading==fade_flash_die) |
| 4544 | ✗ | clk2=19+18*4; | |
| 4545 | else | ||
| 4546 | { | ||
| 4547 | 1200 | clk2 = BSZ ? 15 : 19; | |
| 4548 | |||
| 4549 |
2/2✓ Branch 0 taken 121 times.
✓ Branch 1 taken 1079 times.
|
1200 | if(fading!=fade_blue_poof) |
| 4550 | 1079 | fading=0; | |
| 4551 | } | ||
| 4552 | |||
| 4553 |
2/2✓ Branch 0 taken 1192 times.
✓ Branch 1 taken 8 times.
|
1200 | if(itemguy) |
| 4554 | { | ||
| 4555 | 8 | hasitem&=~2; | |
| 4556 | 8 | item_set=0; | |
| 4557 | 8 | } | |
| 4558 | |||
| 4559 |
5/6✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 971 times.
✓ Branch 3 taken 159 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 971 times.
|
1200 | if(currscr<128 && count_enemy && !script_spawned) |
| 4560 | 971 | game->guys[(currmap<<7)+currscr]-=1; | |
| 4561 | 1200 | } | |
| 4562 | 834286 | } | |
| 4563 | |||
| 4564 | // --==**==-- | ||
| 4565 | |||
| 4566 | // Movement routines that can be used by derived classes as needed | ||
| 4567 | |||
| 4568 | // --==**==-- | ||
| 4569 | |||
| 4570 | 14630 | void enemy::fix_coords(bool bound) | |
| 4571 | { | ||
| 4572 |
1/2✓ Branch 0 taken 14630 times.
✗ Branch 1 not taken.
|
14630 | if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return; |
| 4573 |
1/2✓ Branch 0 taken 14630 times.
✗ Branch 1 not taken.
|
14630 | if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false; |
| 4574 | |||
| 4575 | |||
| 4576 |
2/2✓ Branch 0 taken 2261 times.
✓ Branch 1 taken 12369 times.
|
14630 | if(bound) |
| 4577 | { | ||
| 4578 |
1/2✓ Branch 0 taken 12369 times.
✗ Branch 1 not taken.
|
12369 | if ( ((unsigned)(id&0xFFF)) < MAXGUYS ) |
| 4579 | { | ||
| 4580 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 12369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
12369 | x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf)); |
| 4581 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 12369 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
12369 | y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf)); |
| 4582 | 12369 | } | |
| 4583 | else | ||
| 4584 | { | ||
| 4585 | ✗ | x=vbound(x, 0_zf,240_zf); | |
| 4586 | ✗ | y=vbound(y, 0_zf,160_zf); | |
| 4587 | } | ||
| 4588 | 12369 | } | |
| 4589 | |||
| 4590 |
5/10✓ Branch 0 taken 14630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14630 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14630 times.
|
14630 | if(!OUTOFBOUNDS) |
| 4591 | { | ||
| 4592 | /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0)); | ||
| 4593 | |||
| 4594 | if(isSideViewGravity()) | ||
| 4595 | y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0)); | ||
| 4596 | else | ||
| 4597 | y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0)); | ||
| 4598 | */ | ||
| 4599 | 14630 | do_fix(x, 16, true); | |
| 4600 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14630 times.
|
14630 | if(isSideViewGravity()) |
| 4601 | ✗ | do_fix(y,8,true); | |
| 4602 | 14630 | else do_fix(y,16,true); | |
| 4603 | 14630 | } | |
| 4604 | 14630 | } | |
| 4605 | 396 | bool enemy::cannotpenetrate() | |
| 4606 | { | ||
| 4607 |
4/4✓ Branch 0 taken 369 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 365 times.
|
396 | return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA); |
| 4608 | } | ||
| 4609 | |||
| 4610 | 3 | bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2) | |
| 4611 | { | ||
| 4612 | bool ok; | ||
| 4613 | 3 | int32_t dx = 0, dy = 0; | |
| 4614 | 3 | int32_t sv = 8; | |
| 4615 | |||
| 4616 | //Why is this here??? Why is it needed??? | ||
| 4617 | 3 | s += 0.5; // Make the ints round; doesn't seem to cause any problems. | |
| 4618 | |||
| 4619 |
2/9✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
3 | switch(ndir) |
| 4620 | { | ||
| 4621 | case 8: | ||
| 4622 | case up: | ||
| 4623 | ✗ | if(canfall(id) && isSideViewGravity()) | |
| 4624 | ✗ | return false; | |
| 4625 | |||
| 4626 | ✗ | dy = dy1-s; | |
| 4627 | ✗ | special = (special==spw_clipbottomright)?spw_none:special; | |
| 4628 | ✗ | ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special); | |
| 4629 | ✗ | break; | |
| 4630 | |||
| 4631 | case 12: | ||
| 4632 | case down: | ||
| 4633 | ✗ | if(canfall(id) && isSideViewGravity()) | |
| 4634 | ✗ | return false; | |
| 4635 | |||
| 4636 | ✗ | dy = dy2+s; | |
| 4637 | ✗ | ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special); | |
| 4638 | ✗ | break; | |
| 4639 | |||
| 4640 | case 14: | ||
| 4641 | case left: | ||
| 4642 | ✗ | dx = dx1-s; | |
| 4643 | ✗ | sv = ((isSideViewGravity())?7:8); | |
| 4644 | ✗ | special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special; | |
| 4645 | ✗ | ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special); | |
| 4646 | ✗ | break; | |
| 4647 | |||
| 4648 | case 10: | ||
| 4649 | case right: | ||
| 4650 | ✗ | dx = dx2+s; | |
| 4651 | ✗ | sv = ((isSideViewGravity())?7:8); | |
| 4652 | ✗ | ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special); | |
| 4653 | ✗ | break; | |
| 4654 | |||
| 4655 | case 9: | ||
| 4656 | case r_up: | ||
| 4657 | 2 | dx = dx2+s; | |
| 4658 | 2 | dy = dy1-s; | |
| 4659 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) && |
| 4660 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special); |
| 4661 | 2 | break; | |
| 4662 | |||
| 4663 | case 11: | ||
| 4664 | case r_down: | ||
| 4665 | ✗ | dx = dx2+s; | |
| 4666 | ✗ | dx = dy2+s; | |
| 4667 | ✗ | ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) && | |
| 4668 | ✗ | !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special); | |
| 4669 | ✗ | break; | |
| 4670 | |||
| 4671 | case 13: | ||
| 4672 | case l_down: | ||
| 4673 | 1 | dx = dx1-s; | |
| 4674 | 1 | dy = dy2+s; | |
| 4675 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) && |
| 4676 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special); |
| 4677 | 1 | break; | |
| 4678 | |||
| 4679 | case 15: | ||
| 4680 | case l_up: | ||
| 4681 | ✗ | dx = dx1-s; | |
| 4682 | ✗ | dy = dy1-s; | |
| 4683 | ✗ | ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) && | |
| 4684 | ✗ | !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special); | |
| 4685 | ✗ | break; | |
| 4686 | |||
| 4687 | default: | ||
| 4688 | ✗ | db=99; | |
| 4689 | ✗ | return true; | |
| 4690 | } | ||
| 4691 | |||
| 4692 | 3 | return ok; | |
| 4693 | 3 | } | |
| 4694 | |||
| 4695 | |||
| 4696 | |||
| 4697 | |||
| 4698 | // returns true if next step is ok, false if there is something there | ||
| 4699 | 147800 | bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb) | |
| 4700 | { | ||
| 4701 | 147800 | bool ok = false; //initialise the var, son't just declare it | |
| 4702 | 147800 | int32_t dx = 0, dy = 0; | |
| 4703 | 147800 | int32_t sv = 8; | |
| 4704 | 147800 | int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0; | |
| 4705 | //Why is this here??? Why is it needed??? | ||
| 4706 | 147800 | s += 0.5; // Make the ints round; doesn't seem to cause any problems. | |
| 4707 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 147800 times.
|
147800 | int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0; |
| 4708 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 147800 times.
|
147800 | int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0; |
| 4709 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 147800 times.
|
147800 | int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16; |
| 4710 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 147800 times.
|
147800 | int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16; |
| 4711 | 147800 | bool offgrid = OFFGRID_ENEMY; | |
| 4712 |
2/2✓ Branch 0 taken 146 times.
✓ Branch 1 taken 147654 times.
|
147800 | if(!offgrid) |
| 4713 | { | ||
| 4714 | //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled. | ||
| 4715 |
1/2✓ Branch 0 taken 147654 times.
✗ Branch 1 not taken.
|
147654 | if(usehei<16)usehei=16; |
| 4716 |
1/2✓ Branch 0 taken 147654 times.
✗ Branch 1 not taken.
|
147654 | if(usewid<16)usewid=16; |
| 4717 | 147654 | } | |
| 4718 |
9/9✓ Branch 0 taken 31364 times.
✓ Branch 1 taken 19831 times.
✓ Branch 2 taken 24147 times.
✓ Branch 3 taken 25956 times.
✓ Branch 4 taken 8887 times.
✓ Branch 5 taken 14459 times.
✓ Branch 6 taken 12455 times.
✓ Branch 7 taken 10695 times.
✓ Branch 8 taken 6 times.
|
147800 | switch(ndir) //need to check every 8 pixels between two points |
| 4719 | { | ||
| 4720 | case 8: | ||
| 4721 | case up: | ||
| 4722 | { | ||
| 4723 |
3/4✓ Branch 0 taken 6315 times.
✓ Branch 1 taken 25049 times.
✓ Branch 2 taken 6315 times.
✗ Branch 3 not taken.
|
31364 | if(enemycanfall(id) && isSideViewGravity()) |
| 4724 | ✗ | return false; | |
| 4725 | |||
| 4726 | 31364 | dy = dy1-s; | |
| 4727 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 31364 times.
|
31364 | special = (special==spw_clipbottomright)?spw_none:special; |
| 4728 | 31364 | tries = usewid/(offgrid ? 8 : 16); | |
| 4729 | //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei); | ||
| 4730 |
2/2✓ Branch 0 taken 27323 times.
✓ Branch 1 taken 31369 times.
|
58692 | for ( ; tries > 0; --tries ) |
| 4731 | { | ||
| 4732 |
2/2✓ Branch 0 taken 4014 times.
✓ Branch 1 taken 27355 times.
|
31369 | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb); |
| 4733 | 31369 | try_x += (offgrid ? 8 : 16); | |
| 4734 |
2/2✓ Branch 0 taken 27328 times.
✓ Branch 1 taken 4041 times.
|
31369 | if (!ok) break; |
| 4735 | 27328 | } | |
| 4736 |
2/2✓ Branch 0 taken 27323 times.
✓ Branch 1 taken 4041 times.
|
31364 | if(!ok) break; |
| 4737 |
1/2✓ Branch 0 taken 27323 times.
✗ Branch 1 not taken.
|
27323 | if((usewid%16)>0) //Uneven width |
| 4738 | { | ||
| 4739 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb); | |
| 4740 | ✗ | } | |
| 4741 | 27323 | break; | |
| 4742 | } | ||
| 4743 | case 12: | ||
| 4744 | case down: | ||
| 4745 | { | ||
| 4746 |
3/4✓ Branch 0 taken 6598 times.
✓ Branch 1 taken 13233 times.
✓ Branch 2 taken 6598 times.
✗ Branch 3 not taken.
|
19831 | if(enemycanfall(id) && isSideViewGravity()) |
| 4747 | ✗ | return false; | |
| 4748 | |||
| 4749 | 19831 | dy = dy2+s; | |
| 4750 | 19831 | tries = usewid/(offgrid ? 8 : 16); | |
| 4751 | //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei); | ||
| 4752 |
2/2✓ Branch 0 taken 15713 times.
✓ Branch 1 taken 19842 times.
|
35555 | for ( ; tries > 0; --tries ) |
| 4753 | { | ||
| 4754 |
3/4✓ Branch 0 taken 4098 times.
✓ Branch 1 taken 15744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15744 times.
|
19842 | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb); |
| 4755 | 19842 | try_x += (offgrid ? 8 : 16); | |
| 4756 |
2/2✓ Branch 0 taken 15724 times.
✓ Branch 1 taken 4118 times.
|
19842 | if (!ok) break; |
| 4757 | 15724 | } | |
| 4758 |
2/2✓ Branch 0 taken 15713 times.
✓ Branch 1 taken 4118 times.
|
19831 | if(!ok) break; |
| 4759 |
1/2✓ Branch 0 taken 15713 times.
✗ Branch 1 not taken.
|
15713 | if((usewid%16)>0) //Uneven width |
| 4760 | { | ||
| 4761 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb); | |
| 4762 | ✗ | } | |
| 4763 | 15713 | break; | |
| 4764 | } | ||
| 4765 | case 14: | ||
| 4766 | case left: | ||
| 4767 | { | ||
| 4768 | 24147 | dx = dx1-s; | |
| 4769 | 24147 | sv = ((isSideViewGravity())?7:0); | |
| 4770 |
3/4✓ Branch 0 taken 24147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 24139 times.
|
24147 | special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special; |
| 4771 | 24147 | tries = usehei/(offgrid ? 8 : 16); | |
| 4772 | //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei); | ||
| 4773 |
2/2✓ Branch 0 taken 20817 times.
✓ Branch 1 taken 24155 times.
|
44972 | for ( ; tries > 0; --tries ) |
| 4774 | { | ||
| 4775 |
2/2✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 20840 times.
|
24155 | ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb); |
| 4776 | 24155 | try_y += (offgrid ? 8 : 16); | |
| 4777 |
2/2✓ Branch 0 taken 20825 times.
✓ Branch 1 taken 3330 times.
|
24155 | if (!ok) break; |
| 4778 | 20825 | } | |
| 4779 |
2/2✓ Branch 0 taken 20817 times.
✓ Branch 1 taken 3330 times.
|
24147 | if(!ok) break; |
| 4780 |
1/2✓ Branch 0 taken 20817 times.
✗ Branch 1 not taken.
|
20817 | if((usehei%16)>0) //Uneven height |
| 4781 | { | ||
| 4782 | ✗ | ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb); | |
| 4783 | ✗ | } | |
| 4784 | 20817 | break; | |
| 4785 | } | ||
| 4786 | case 10: | ||
| 4787 | case right: | ||
| 4788 | { | ||
| 4789 | 25956 | dx = dx2+s; | |
| 4790 | 25956 | sv = ((isSideViewGravity())?7:0); | |
| 4791 | 25956 | tries = usehei/(offgrid ? 8 : 16); | |
| 4792 | //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei); | ||
| 4793 |
2/2✓ Branch 0 taken 22345 times.
✓ Branch 1 taken 25967 times.
|
48312 | for ( ; tries > 0; --tries ) |
| 4794 | { | ||
| 4795 |
3/4✓ Branch 0 taken 3602 times.
✓ Branch 1 taken 22365 times.
✓ Branch 2 taken 22365 times.
✗ Branch 3 not taken.
|
25967 | ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb); |
| 4796 | 25967 | try_y += (offgrid ? 8 : 16); | |
| 4797 |
2/2✓ Branch 0 taken 22356 times.
✓ Branch 1 taken 3611 times.
|
25967 | if (!ok) break; |
| 4798 | 22356 | } | |
| 4799 |
2/2✓ Branch 0 taken 22345 times.
✓ Branch 1 taken 3611 times.
|
25956 | if(!ok) break; |
| 4800 |
1/2✓ Branch 0 taken 22345 times.
✗ Branch 1 not taken.
|
22345 | if((usehei%16)>0) //Uneven height |
| 4801 | { | ||
| 4802 | ✗ | ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb); | |
| 4803 | ✗ | } | |
| 4804 | 22345 | break; | |
| 4805 | } | ||
| 4806 | case 9: | ||
| 4807 | case r_up: | ||
| 4808 | { | ||
| 4809 | 8887 | dx = dx2+s; | |
| 4810 | 8887 | dy = dy1-s; | |
| 4811 | 8887 | int32_t tries_x = usewid/(offgrid ? 8 : 16); | |
| 4812 | 8887 | sv = ((isSideViewGravity())?7:0); | |
| 4813 |
2/2✓ Branch 0 taken 8636 times.
✓ Branch 1 taken 8887 times.
|
17523 | for ( ; tries_x > 0; --tries_x ) |
| 4814 | { | ||
| 4815 | 8887 | int32_t tries_y = usehei/(offgrid ? 8 : 16); | |
| 4816 | 8887 | try_y = 0; | |
| 4817 |
2/2✓ Branch 0 taken 8636 times.
✓ Branch 1 taken 8887 times.
|
17523 | for ( ; tries_y > 0; --tries_y ) |
| 4818 | { | ||
| 4819 |
4/4✓ Branch 0 taken 8738 times.
✓ Branch 1 taken 149 times.
✓ Branch 2 taken 8659 times.
✓ Branch 3 taken 79 times.
|
17546 | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && |
| 4820 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8647 times.
|
8659 | !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb); |
| 4821 | 8887 | try_y += (offgrid ? 8 : 16); | |
| 4822 |
2/2✓ Branch 0 taken 8636 times.
✓ Branch 1 taken 251 times.
|
8887 | if (!ok) break; |
| 4823 | 8636 | } | |
| 4824 |
2/2✓ Branch 0 taken 8636 times.
✓ Branch 1 taken 251 times.
|
8887 | if (!ok) break; |
| 4825 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8636 times.
|
8636 | if((usehei%16)>0) //Uneven height |
| 4826 | { | ||
| 4827 | ✗ | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && | |
| 4828 | ✗ | !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb); | |
| 4829 | ✗ | } | |
| 4830 | 8636 | try_x += (offgrid ? 8 : 16); | |
| 4831 | 8636 | } | |
| 4832 |
2/2✓ Branch 0 taken 8636 times.
✓ Branch 1 taken 251 times.
|
8887 | if(!ok) break; |
| 4833 |
1/2✓ Branch 0 taken 8636 times.
✗ Branch 1 not taken.
|
8636 | if((usewid%16)>0) //Uneven width |
| 4834 | { | ||
| 4835 | ✗ | int32_t tries_y = usehei/(offgrid ? 8 : 16); | |
| 4836 | ✗ | try_y = 0; | |
| 4837 | ✗ | for ( ; tries_y > 0; --tries_y ) | |
| 4838 | { | ||
| 4839 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && | |
| 4840 | ✗ | !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb); | |
| 4841 | ✗ | try_y += (offgrid ? 8 : 16); | |
| 4842 | ✗ | if (!ok) break; | |
| 4843 | ✗ | } | |
| 4844 | ✗ | if (!ok) break; | |
| 4845 | ✗ | if((usehei%16)>0) //Uneven height | |
| 4846 | { | ||
| 4847 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && | |
| 4848 | ✗ | !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb); | |
| 4849 | ✗ | } | |
| 4850 | ✗ | } | |
| 4851 | 8636 | break; | |
| 4852 | } | ||
| 4853 | case 11: | ||
| 4854 | case r_down: | ||
| 4855 | { | ||
| 4856 | 14459 | dx = dx2+s; | |
| 4857 | 14459 | dx = dy2+s; | |
| 4858 | 14459 | int32_t tries_x = usewid/(offgrid ? 8 : 16); | |
| 4859 | //sv = ((isSideViewGravity())?7:0); | ||
| 4860 |
2/2✓ Branch 0 taken 14255 times.
✓ Branch 1 taken 14459 times.
|
28714 | for ( ; tries_x > 0; --tries_x ) |
| 4861 | { | ||
| 4862 | 14459 | int32_t tries_y = usehei/(offgrid ? 8 : 16); | |
| 4863 | 14459 | try_y = 0; | |
| 4864 |
2/2✓ Branch 0 taken 14255 times.
✓ Branch 1 taken 14459 times.
|
28714 | for ( ; tries_y > 0; --tries_y ) |
| 4865 | { | ||
| 4866 |
4/4✓ Branch 0 taken 14452 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 14268 times.
✓ Branch 3 taken 184 times.
|
28727 | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && |
| 4867 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14268 times.
|
14268 | !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb); |
| 4868 | 14459 | try_y += (offgrid ? 8 : 16); | |
| 4869 |
2/2✓ Branch 0 taken 14255 times.
✓ Branch 1 taken 204 times.
|
14459 | if (!ok) break; |
| 4870 | 14255 | } | |
| 4871 |
2/2✓ Branch 0 taken 14255 times.
✓ Branch 1 taken 204 times.
|
14459 | if (!ok) break; |
| 4872 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14255 times.
|
14255 | if((usehei%16)>0) //Uneven height |
| 4873 | { | ||
| 4874 | ✗ | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && | |
| 4875 | ✗ | !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb); | |
| 4876 | ✗ | } | |
| 4877 | 14255 | try_x += (offgrid ? 8 : 16); | |
| 4878 | 14255 | } | |
| 4879 |
2/2✓ Branch 0 taken 14255 times.
✓ Branch 1 taken 204 times.
|
14459 | if(!ok) break; |
| 4880 |
1/2✓ Branch 0 taken 14255 times.
✗ Branch 1 not taken.
|
14255 | if((usewid%16)>0) //Uneven width |
| 4881 | { | ||
| 4882 | ✗ | int32_t tries_y = usehei/(offgrid ? 8 : 16); | |
| 4883 | ✗ | try_y = 0; | |
| 4884 | ✗ | for ( ; tries_y > 0; --tries_y ) | |
| 4885 | { | ||
| 4886 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && | |
| 4887 | ✗ | !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb); | |
| 4888 | ✗ | try_y += (offgrid ? 8 : 16); | |
| 4889 | ✗ | if (!ok) break; | |
| 4890 | ✗ | } | |
| 4891 | ✗ | if (!ok) break; | |
| 4892 | ✗ | if((usehei%16)>0) //Uneven height | |
| 4893 | { | ||
| 4894 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && | |
| 4895 | ✗ | !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb); | |
| 4896 | ✗ | } | |
| 4897 | ✗ | } | |
| 4898 | 14255 | break; | |
| 4899 | } | ||
| 4900 | case 13: | ||
| 4901 | case l_down: | ||
| 4902 | { | ||
| 4903 | 12455 | dx = dx1-s; | |
| 4904 | 12455 | dy = dy2+s; | |
| 4905 | 12455 | int32_t tries_x = usewid/(offgrid ? 8 : 16); | |
| 4906 | //sv = ((isSideViewGravity())?7:0); | ||
| 4907 |
2/2✓ Branch 0 taken 12251 times.
✓ Branch 1 taken 12455 times.
|
24706 | for ( ; tries_x > 0; --tries_x ) |
| 4908 | { | ||
| 4909 | 12455 | int32_t tries_y = usehei/(offgrid ? 8 : 16); | |
| 4910 | 12455 | try_y = 0; | |
| 4911 |
2/2✓ Branch 0 taken 12251 times.
✓ Branch 1 taken 12455 times.
|
24706 | for ( ; tries_y > 0; --tries_y ) |
| 4912 | { | ||
| 4913 |
4/4✓ Branch 0 taken 12327 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 12259 times.
✓ Branch 3 taken 68 times.
|
24714 | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && |
| 4914 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 12251 times.
|
12259 | !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb); |
| 4915 | 12455 | try_y += (offgrid ? 8 : 16); | |
| 4916 |
2/2✓ Branch 0 taken 12251 times.
✓ Branch 1 taken 204 times.
|
12455 | if (!ok) break; |
| 4917 | 12251 | } | |
| 4918 |
2/2✓ Branch 0 taken 12251 times.
✓ Branch 1 taken 204 times.
|
12455 | if (!ok) break; |
| 4919 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12251 times.
|
12251 | if((usehei%16)>0) //Uneven height |
| 4920 | { | ||
| 4921 | ✗ | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && | |
| 4922 | ✗ | !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb); | |
| 4923 | ✗ | } | |
| 4924 | 12251 | try_x += (offgrid ? 8 : 16); | |
| 4925 | 12251 | } | |
| 4926 |
2/2✓ Branch 0 taken 12251 times.
✓ Branch 1 taken 204 times.
|
12455 | if(!ok) break; |
| 4927 |
1/2✓ Branch 0 taken 12251 times.
✗ Branch 1 not taken.
|
12251 | if((usewid%16)>0) //Uneven width |
| 4928 | { | ||
| 4929 | ✗ | int32_t tries_y = usehei/(offgrid ? 8 : 16); | |
| 4930 | ✗ | try_y = 0; | |
| 4931 | ✗ | for ( ; tries_y > 0; --tries_y ) | |
| 4932 | { | ||
| 4933 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && | |
| 4934 | ✗ | !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb); | |
| 4935 | ✗ | try_y += (offgrid ? 8 : 16); | |
| 4936 | ✗ | if (!ok) break; | |
| 4937 | ✗ | } | |
| 4938 | ✗ | if (!ok) break; | |
| 4939 | ✗ | if((usehei%16)>0) //Uneven height | |
| 4940 | { | ||
| 4941 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && | |
| 4942 | ✗ | !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb); | |
| 4943 | ✗ | } | |
| 4944 | ✗ | } | |
| 4945 | 12251 | break; | |
| 4946 | } | ||
| 4947 | case 15: | ||
| 4948 | case l_up: | ||
| 4949 | { | ||
| 4950 | 10695 | dx = dx1-s; | |
| 4951 | 10695 | dy = dy1-s; | |
| 4952 | 10695 | int32_t tries_x = usewid/(offgrid ? 8 : 16); | |
| 4953 | 10695 | sv = ((isSideViewGravity())?7:0); | |
| 4954 |
2/2✓ Branch 0 taken 10467 times.
✓ Branch 1 taken 10695 times.
|
21162 | for ( ; tries_x > 0; --tries_x ) |
| 4955 | { | ||
| 4956 | 10695 | int32_t tries_y = usehei/(offgrid ? 8 : 16); | |
| 4957 | 10695 | try_y = 0; | |
| 4958 |
2/2✓ Branch 0 taken 10467 times.
✓ Branch 1 taken 10695 times.
|
21162 | for ( ; tries_y > 0; --tries_y ) |
| 4959 | { | ||
| 4960 |
4/4✓ Branch 0 taken 10559 times.
✓ Branch 1 taken 136 times.
✓ Branch 2 taken 10490 times.
✓ Branch 3 taken 69 times.
|
21185 | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && |
| 4961 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 10473 times.
|
10490 | !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb); |
| 4962 | 10695 | try_y += (offgrid ? 8 : 16); | |
| 4963 |
2/2✓ Branch 0 taken 10467 times.
✓ Branch 1 taken 228 times.
|
10695 | if (!ok) break; |
| 4964 | 10467 | } | |
| 4965 |
2/2✓ Branch 0 taken 10467 times.
✓ Branch 1 taken 228 times.
|
10695 | if (!ok) break; |
| 4966 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10467 times.
|
10467 | if((usehei%16)>0) //Uneven height |
| 4967 | { | ||
| 4968 | ✗ | ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && | |
| 4969 | ✗ | !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb); | |
| 4970 | ✗ | } | |
| 4971 | 10467 | try_x += (offgrid ? 8 : 16); | |
| 4972 | 10467 | } | |
| 4973 |
2/2✓ Branch 0 taken 10467 times.
✓ Branch 1 taken 228 times.
|
10695 | if(!ok) break; |
| 4974 |
1/2✓ Branch 0 taken 10467 times.
✗ Branch 1 not taken.
|
10467 | if((usewid%16)>0) //Uneven width |
| 4975 | { | ||
| 4976 | ✗ | int32_t tries_y = usehei/(offgrid ? 8 : 16); | |
| 4977 | ✗ | try_y = 0; | |
| 4978 | ✗ | for ( ; tries_y > 0; --tries_y ) | |
| 4979 | { | ||
| 4980 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && | |
| 4981 | ✗ | !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb); | |
| 4982 | ✗ | try_y += (offgrid ? 8 : 16); | |
| 4983 | ✗ | if (!ok) break; | |
| 4984 | ✗ | } | |
| 4985 | ✗ | if (!ok) break; | |
| 4986 | ✗ | if((usehei%16)>0) //Uneven height | |
| 4987 | { | ||
| 4988 | ✗ | ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && | |
| 4989 | ✗ | !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb); | |
| 4990 | ✗ | } | |
| 4991 | ✗ | } | |
| 4992 | 10467 | break; | |
| 4993 | } | ||
| 4994 | default: | ||
| 4995 | 6 | db=99; | |
| 4996 | 6 | return true; | |
| 4997 | } | ||
| 4998 | //Z_eventlog("\n"); | ||
| 4999 | 147794 | return ok; | |
| 5000 | 147800 | } | |
| 5001 | |||
| 5002 | |||
| 5003 | 98256 | bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb) | |
| 5004 | { | ||
| 5005 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 98256 times.
|
98256 | int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16; |
| 5006 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 98256 times.
|
98256 | int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16; |
| 5007 |
1/2✓ Branch 0 taken 98256 times.
✗ Branch 1 not taken.
|
98256 | if (usewid % 16 != 0) usewid += (16 - (usewid%16)); |
| 5008 |
1/2✓ Branch 0 taken 98256 times.
✗ Branch 1 not taken.
|
98256 | if (usehei % 16 != 0) usehei += (16 - (usehei%16)); |
| 5009 | 98256 | --usewid; | |
| 5010 | 98256 | --usehei; | |
| 5011 | 98256 | return canmove(ndir,s,special,0,-8,usewid,usehei,kb); | |
| 5012 | } | ||
| 5013 | |||
| 5014 | 28075 | bool enemy::canmove(int32_t ndir,int32_t special, bool kb) | |
| 5015 | { | ||
| 5016 | 28075 | bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN | |
| 5017 | |||
| 5018 |
4/4✓ Branch 0 taken 49 times.
✓ Branch 1 taken 28026 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 12 times.
|
28075 | if(special==spw_clipright&&ndir==right) |
| 5019 | { | ||
| 5020 | 12 | dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb); | |
| 5021 | 12 | } | |
| 5022 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 28075 times.
|
28075 | int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16; |
| 5023 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 28075 times.
|
28075 | int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16; |
| 5024 |
1/2✓ Branch 0 taken 28075 times.
✗ Branch 1 not taken.
|
28075 | if (usewid % 16 != 0) usewid += (16 - (usewid%16)); |
| 5025 |
1/2✓ Branch 0 taken 28075 times.
✗ Branch 1 not taken.
|
28075 | if (usehei % 16 != 0) usehei += (16 - (usehei%16)); |
| 5026 | 28075 | --usewid; | |
| 5027 | 28075 | --usehei; | |
| 5028 |
2/2✓ Branch 0 taken 14160 times.
✓ Branch 1 taken 13915 times.
|
28075 | return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move; |
| 5029 | } | ||
| 5030 | |||
| 5031 | 3220 | bool enemy::canmove(int32_t ndir, bool kb) | |
| 5032 | { | ||
| 5033 | 3220 | return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb); | |
| 5034 | } | ||
| 5035 | |||
| 5036 | // 8-directional | ||
| 5037 | 3 | void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2) | |
| 5038 | { | ||
| 5039 | 3 | int32_t ndir=0; | |
| 5040 | |||
| 5041 | // can move straight, check if it wants to turn | ||
| 5042 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2)) |
| 5043 | { | ||
| 5044 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3 | if(grumble && (zc_oldrand()&4)<grumble) //Homing |
| 5045 | { | ||
| 5046 | ✗ | int32_t w = Lwpns.idFirst(wBait); | |
| 5047 | |||
| 5048 | ✗ | if(w>=0) | |
| 5049 | { | ||
| 5050 | ✗ | int32_t bx = Lwpns.spr(w)->x; | |
| 5051 | ✗ | int32_t by = Lwpns.spr(w)->y; | |
| 5052 | |||
| 5053 | ✗ | ndir = (bx<x) ? left : (bx!=x) ? right : 0; | |
| 5054 | |||
| 5055 | ✗ | if(abs(int32_t(y)-by)>14) | |
| 5056 | { | ||
| 5057 | ✗ | if(ndir>0) // Already left or right | |
| 5058 | { | ||
| 5059 | // Making the diagonal directions | ||
| 5060 | ✗ | ndir += (by<y) ? 2 : 4; | |
| 5061 | ✗ | } | |
| 5062 | else | ||
| 5063 | { | ||
| 5064 | ✗ | ndir = (by<y) ? up : down; | |
| 5065 | } | ||
| 5066 | ✗ | } | |
| 5067 | |||
| 5068 | ✗ | if(canmove(ndir,special,false)) | |
| 5069 | { | ||
| 5070 | ✗ | dir=ndir; | |
| 5071 | ✗ | return; | |
| 5072 | } | ||
| 5073 | ✗ | } | |
| 5074 | ✗ | } | |
| 5075 | |||
| 5076 | // Homing added. | ||
| 5077 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3 | if(newhoming && (zc_oldrand()&255)<newhoming) |
| 5078 | { | ||
| 5079 | ✗ | ndir = lined_up(8,true); | |
| 5080 | |||
| 5081 | ✗ | if(ndir>=0 && canmove(ndir,special,false)) | |
| 5082 | { | ||
| 5083 | ✗ | dir=ndir; | |
| 5084 | ✗ | } | |
| 5085 | |||
| 5086 | ✗ | return; | |
| 5087 | } | ||
| 5088 | |||
| 5089 | 3 | int32_t r=zc_oldrand(); | |
| 5090 | |||
| 5091 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | if(newrate>0 && !(r%newrate)) |
| 5092 | { | ||
| 5093 | 3 | ndir = ((dir+((r&64)?-1:1))&7)+8; | |
| 5094 | 3 | int32_t ndir2=((dir+((r&64)?1:-1))&7)+8; | |
| 5095 | |||
| 5096 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false)) |
| 5097 | 3 | dir=ndir; | |
| 5098 | ✗ | else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false)) | |
| 5099 | ✗ | dir=ndir2; | |
| 5100 | |||
| 5101 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left |
| 5102 | // due to numerous lost fractional components. -L | ||
| 5103 | { | ||
| 5104 | ✗ | x.doFloor(); | |
| 5105 | ✗ | y.doFloor(); | |
| 5106 | ✗ | } | |
| 5107 | 3 | } | |
| 5108 | |||
| 5109 | 3 | return; | |
| 5110 | } | ||
| 5111 | |||
| 5112 | // can't move straight, must turn | ||
| 5113 | ✗ | int32_t i=0; | |
| 5114 | |||
| 5115 | ✗ | for(; i<32; i++) // Try random dir | |
| 5116 | { | ||
| 5117 | ✗ | ndir=(zc_oldrand()&7)+8; | |
| 5118 | |||
| 5119 | ✗ | if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false)) | |
| 5120 | ✗ | break; | |
| 5121 | ✗ | } | |
| 5122 | |||
| 5123 | ✗ | if(i==32) | |
| 5124 | { | ||
| 5125 | ✗ | for(ndir=8; ndir<16; ndir++) | |
| 5126 | { | ||
| 5127 | ✗ | if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false)) | |
| 5128 | ✗ | goto ok; | |
| 5129 | ✗ | } | |
| 5130 | |||
| 5131 | ✗ | ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1 | |
| 5132 | ✗ | } | |
| 5133 | |||
| 5134 | ok: | ||
| 5135 | ✗ | dir=ndir; | |
| 5136 | ✗ | x.doFloor(); | |
| 5137 | ✗ | y.doFloor(); | |
| 5138 | 3 | } | |
| 5139 | |||
| 5140 | 12240 | void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2) | |
| 5141 | { | ||
| 5142 | 12240 | int32_t ndir=0; | |
| 5143 | |||
| 5144 | // can move straight, check if it wants to turn | ||
| 5145 |
2/2✓ Branch 0 taken 11748 times.
✓ Branch 1 taken 492 times.
|
12240 | if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false)) |
| 5146 | { | ||
| 5147 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11748 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11748 | if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing |
| 5148 | { | ||
| 5149 | ✗ | int32_t i = Lwpns.idFirst(wBait); | |
| 5150 | ✗ | if(i >= 0) //idfirst returns -1 if it can't find any | |
| 5151 | { | ||
| 5152 | ✗ | weapon *w = (weapon*)Lwpns.spr(i); | |
| 5153 | ✗ | if (get_qr(qr_FIND_CLOSEST_BAIT)) | |
| 5154 | { | ||
| 5155 | int32_t currentrange; | ||
| 5156 | ✗ | if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y); | |
| 5157 | ✗ | else currentrange = -1; | |
| 5158 | ✗ | int curid = i; | |
| 5159 | ✗ | ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee | |
| 5160 | ✗ | for(; i<Lwpns.Count(); ++i) | |
| 5161 | { | ||
| 5162 | ✗ | weapon *lw = (weapon*)Lwpns.spr(i); | |
| 5163 | ✗ | if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0)) | |
| 5164 | { | ||
| 5165 | ✗ | currentrange = distance(x, y, lw->x, lw->y); | |
| 5166 | ✗ | curid = i; | |
| 5167 | ✗ | } | |
| 5168 | ✗ | } | |
| 5169 | ✗ | i = curid; | |
| 5170 | ✗ | if (currentrange == -1) i = -1; | |
| 5171 | ✗ | } | |
| 5172 | else | ||
| 5173 | { | ||
| 5174 | ✗ | if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1; | |
| 5175 | } | ||
| 5176 | ✗ | if(i>=0) | |
| 5177 | { | ||
| 5178 | ✗ | int32_t bx = Lwpns.spr(i)->x; | |
| 5179 | ✗ | int32_t by = Lwpns.spr(i)->y; | |
| 5180 | |||
| 5181 | ✗ | ndir = (bx<x) ? left : (bx!=x) ? right : 0; | |
| 5182 | |||
| 5183 | ✗ | if(abs(int32_t(y)-by)>14) | |
| 5184 | { | ||
| 5185 | ✗ | if(ndir>0) // Already left or right | |
| 5186 | { | ||
| 5187 | // Making the diagonal directions | ||
| 5188 | ✗ | ndir += (by<y) ? 2 : 4; | |
| 5189 | ✗ | } | |
| 5190 | else | ||
| 5191 | { | ||
| 5192 | ✗ | ndir = (by<y) ? up : down; | |
| 5193 | } | ||
| 5194 | ✗ | } | |
| 5195 | ✗ | if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir]; | |
| 5196 | ✗ | if(canmove(ndir,special,false)) | |
| 5197 | { | ||
| 5198 | ✗ | dir=ndir; | |
| 5199 | ✗ | return; | |
| 5200 | } | ||
| 5201 | ✗ | } | |
| 5202 | ✗ | } | |
| 5203 | ✗ | } | |
| 5204 | |||
| 5205 | // Homing added. | ||
| 5206 |
4/4✓ Branch 0 taken 170 times.
✓ Branch 1 taken 11578 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 96 times.
|
11748 | if(newhoming && (zc_oldrand()&255)<abs(newhoming)) |
| 5207 | { | ||
| 5208 | 96 | ndir = lined_up(8,true); | |
| 5209 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
96 | if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir]; |
| 5210 |
3/4✓ Branch 0 taken 55 times.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
|
96 | if(ndir>=0 && canmove(ndir,special,false)) |
| 5211 | { | ||
| 5212 | 55 | dir=ndir; | |
| 5213 | 55 | } | |
| 5214 | |||
| 5215 | 96 | return; | |
| 5216 | } | ||
| 5217 | |||
| 5218 | 11652 | int32_t r=zc_oldrand(); | |
| 5219 | |||
| 5220 |
4/4✓ Branch 0 taken 5390 times.
✓ Branch 1 taken 6262 times.
✓ Branch 2 taken 3062 times.
✓ Branch 3 taken 2328 times.
|
11652 | if(newrate>0 && !(r%newrate)) |
| 5221 | { | ||
| 5222 | 2328 | ndir = ((dir+((r&64)?-1:1))&7)+8; | |
| 5223 | 2328 | int32_t ndir2=((dir+((r&64)?1:-1))&7)+8; | |
| 5224 | |||
| 5225 |
2/2✓ Branch 0 taken 2269 times.
✓ Branch 1 taken 59 times.
|
2328 | if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false)) |
| 5226 | 2269 | dir=ndir; | |
| 5227 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
|
59 | else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false)) |
| 5228 | 59 | dir=ndir2; | |
| 5229 | |||
| 5230 |
4/4✓ Branch 0 taken 2269 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 2171 times.
✓ Branch 3 taken 98 times.
|
2328 | if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left |
| 5231 | // due to numerous lost fractional components. -L | ||
| 5232 | { | ||
| 5233 | 98 | x.doFloor(); | |
| 5234 | 98 | y.doFloor(); | |
| 5235 | 98 | } | |
| 5236 | 2328 | } | |
| 5237 | |||
| 5238 | 11652 | return; | |
| 5239 | } | ||
| 5240 | |||
| 5241 | // can't move straight, must turn | ||
| 5242 | 492 | int32_t i=0; | |
| 5243 | |||
| 5244 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 873 times.
|
873 | for(; i<32; i++) // Try random dir |
| 5245 | { | ||
| 5246 | 873 | ndir=(zc_oldrand()&7)+8; | |
| 5247 | |||
| 5248 |
2/2✓ Branch 0 taken 381 times.
✓ Branch 1 taken 492 times.
|
873 | if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false)) |
| 5249 | 492 | break; | |
| 5250 | 381 | } | |
| 5251 | |||
| 5252 |
1/2✓ Branch 0 taken 492 times.
✗ Branch 1 not taken.
|
492 | if(i==32) |
| 5253 | { | ||
| 5254 | ✗ | for(ndir=8; ndir<16; ndir++) | |
| 5255 | { | ||
| 5256 | ✗ | if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false)) | |
| 5257 | ✗ | goto ok; | |
| 5258 | ✗ | } | |
| 5259 | |||
| 5260 | ✗ | ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1 | |
| 5261 | ✗ | } | |
| 5262 | |||
| 5263 | ok: | ||
| 5264 | 492 | dir=ndir; | |
| 5265 | 492 | x.doFloor(); | |
| 5266 | 492 | y.doFloor(); | |
| 5267 | 12240 | } | |
| 5268 | |||
| 5269 | 12111 | void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special) | |
| 5270 | { | ||
| 5271 | 12111 | newdir_8(newrate,newhoming,special,0,-8,15,15); | |
| 5272 | 12111 | } | |
| 5273 | |||
| 5274 | 3 | void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special) | |
| 5275 | { | ||
| 5276 | 3 | newdir_8_old(newrate,newhoming,special,0,-8,15,15); | |
| 5277 | 3 | } | |
| 5278 | |||
| 5279 | // makes the enemy slide backwards when hit | ||
| 5280 | // sclk: first byte is clk, second byte is dir | ||
| 5281 | // makes the enemy slide backwards when hit | ||
| 5282 | // sclk: first byte is clk, second byte is dir | ||
| 5283 | 387749 | int32_t enemy::slide() | |
| 5284 | { | ||
| 5285 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 387749 times.
|
387749 | if(script_knockback_clk!=0) //scripted knockback |
| 5286 | { | ||
| 5287 | ✗ | sclk = 0; | |
| 5288 | ✗ | return 1; //scripted knockback ran | |
| 5289 | } | ||
| 5290 |
5/6✓ Branch 0 taken 2919 times.
✓ Branch 1 taken 384830 times.
✓ Branch 2 taken 438 times.
✓ Branch 3 taken 2481 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 438 times.
|
387749 | if(sclk==0 || (hp<=0 && !immortal)) |
| 5291 | 385268 | return 0; | |
| 5292 | |||
| 5293 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2481 times.
|
2481 | if(knockbackflags & FLAG_NOSLIDE) |
| 5294 | { | ||
| 5295 | ✗ | sclk = 0; | |
| 5296 | ✗ | if(!OFFGRID_ENEMY) | |
| 5297 | { | ||
| 5298 | //Fix to grid | ||
| 5299 | //x = (int32_t(x)+8)-((int32_t(x)+8)%16); | ||
| 5300 | //y = (int32_t(y)+8)-((int32_t(y)+8)%16); | ||
| 5301 | ✗ | do_fix(x, 16, true); | |
| 5302 | ✗ | do_fix(y, 16, true); | |
| 5303 | ✗ | } | |
| 5304 | ✗ | return 0; | |
| 5305 | } | ||
| 5306 |
8/10✓ Branch 0 taken 269 times.
✓ Branch 1 taken 2212 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 264 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 200 times.
✓ Branch 7 taken 64 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
|
2481 | if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true))) |
| 5307 | { | ||
| 5308 | 64 | sclk=0; | |
| 5309 | 64 | return 0; | |
| 5310 | } | ||
| 5311 | |||
| 5312 | 2417 | --sclk; | |
| 5313 | |||
| 5314 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 275 times.
✓ Branch 2 taken 179 times.
✓ Branch 3 taken 827 times.
✓ Branch 4 taken 1136 times.
|
2417 | switch(sclk>>8) |
| 5315 | { | ||
| 5316 | case up: | ||
| 5317 | { | ||
| 5318 |
3/4✓ Branch 0 taken 38 times.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 275 times.
|
275 | if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires |
| 5319 | { | ||
| 5320 | ✗ | sclk=0; | |
| 5321 | ✗ | return 0; | |
| 5322 | } | ||
| 5323 |
4/4✓ Branch 0 taken 38 times.
✓ Branch 1 taken 237 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 6 times.
|
275 | if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires |
| 5324 | |||
| 5325 | 269 | break; | |
| 5326 | } | ||
| 5327 | case down: | ||
| 5328 | { | ||
| 5329 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
|
179 | if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug. |
| 5330 | { | ||
| 5331 | ✗ | sclk=0; | |
| 5332 | ✗ | return 0; | |
| 5333 | } | ||
| 5334 |
4/4✓ Branch 0 taken 25 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 2 times.
|
179 | if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires |
| 5335 | |||
| 5336 | 177 | break; | |
| 5337 | } | ||
| 5338 | case left: | ||
| 5339 | { | ||
| 5340 |
3/4✓ Branch 0 taken 38 times.
✓ Branch 1 taken 789 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 827 times.
|
827 | if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) |
| 5341 | { | ||
| 5342 | ✗ | sclk=0; | |
| 5343 | ✗ | return 0; | |
| 5344 | } | ||
| 5345 |
4/4✓ Branch 0 taken 38 times.
✓ Branch 1 taken 789 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 6 times.
|
827 | if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } |
| 5346 | |||
| 5347 | 821 | break; | |
| 5348 | } | ||
| 5349 | case right: | ||
| 5350 | { | ||
| 5351 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1136 times.
|
1136 | if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires |
| 5352 | { | ||
| 5353 | ✗ | sclk=0; | |
| 5354 | ✗ | return 0; | |
| 5355 | } | ||
| 5356 |
4/4✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1031 times.
✓ Branch 2 taken 98 times.
✓ Branch 3 taken 7 times.
|
1136 | if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires |
| 5357 | 1129 | break; | |
| 5358 | } | ||
| 5359 | } | ||
| 5360 | |||
| 5361 | 2396 | int32_t move = knockbackSpeed; | |
| 5362 |
2/2✓ Branch 0 taken 2253 times.
✓ Branch 1 taken 2396 times.
|
4649 | while(move>0) |
| 5363 | { | ||
| 5364 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2396 times.
|
2396 | int32_t thismove = zc_min(8, move); |
| 5365 | 2396 | move -= thismove; | |
| 5366 | 2396 | hitdir = (sclk>>8); | |
| 5367 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 269 times.
✓ Branch 2 taken 177 times.
✓ Branch 3 taken 821 times.
✓ Branch 4 taken 1129 times.
|
2396 | switch(sclk>>8) |
| 5368 | { | ||
| 5369 | case up: | ||
| 5370 | 269 | y-=thismove; | |
| 5371 | 269 | break; | |
| 5372 | |||
| 5373 | case down: | ||
| 5374 | 177 | y+=thismove; | |
| 5375 | 177 | break; | |
| 5376 | |||
| 5377 | case left: | ||
| 5378 | 821 | x-=thismove; | |
| 5379 | 821 | break; | |
| 5380 | |||
| 5381 | case right: | ||
| 5382 | 1129 | x+=thismove; | |
| 5383 | 1129 | break; | |
| 5384 | } | ||
| 5385 |
2/2✓ Branch 0 taken 2253 times.
✓ Branch 1 taken 143 times.
|
2396 | if(!canmove(sclk>>8,(zfix)0,0,true)) |
| 5386 | { | ||
| 5387 |
2/3✓ Branch 0 taken 33 times.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
|
143 | switch(sclk>>8) |
| 5388 | { | ||
| 5389 | case up: | ||
| 5390 | case down: | ||
| 5391 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
|
33 | if(y < 0) |
| 5392 | ✗ | y = 0; | |
| 5393 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 29 times.
|
33 | else if((int32_t(y)&15) > 7) |
| 5394 | 4 | y=(int32_t(y)&0xF0)+16; | |
| 5395 | else | ||
| 5396 | 29 | y=(int32_t(y)&0xF0); | |
| 5397 | |||
| 5398 | 33 | break; | |
| 5399 | |||
| 5400 | case left: | ||
| 5401 | case right: | ||
| 5402 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
|
110 | if(x < 0) |
| 5403 | ✗ | x = 0; | |
| 5404 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 78 times.
|
110 | else if((int32_t(x)&15) > 7) |
| 5405 | 32 | x=(int32_t(x)&0xF0)+16; | |
| 5406 | else | ||
| 5407 | 78 | x=(int32_t(x)&0xF0); | |
| 5408 | |||
| 5409 | 110 | break; | |
| 5410 | } | ||
| 5411 | |||
| 5412 | 143 | sclk=0; | |
| 5413 | 143 | clk3=0; | |
| 5414 | 143 | break; | |
| 5415 | } | ||
| 5416 | } | ||
| 5417 | |||
| 5418 |
2/2✓ Branch 0 taken 2194 times.
✓ Branch 1 taken 202 times.
|
2396 | if((sclk&255)==0) |
| 5419 | { | ||
| 5420 | //hitdir = -1; | ||
| 5421 | 202 | sclk=0; | |
| 5422 | 202 | } | |
| 5423 | 2396 | return 2; | |
| 5424 | 387749 | } | |
| 5425 | |||
| 5426 | ✗ | bool enemy::can_slide() | |
| 5427 | { | ||
| 5428 | ✗ | if(sclk==0 || (hp<=0 && !immortal)) | |
| 5429 | ✗ | return false; | |
| 5430 | |||
| 5431 | ✗ | if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true))) | |
| 5432 | { | ||
| 5433 | ✗ | return false; | |
| 5434 | } | ||
| 5435 | |||
| 5436 | ✗ | return true; | |
| 5437 | ✗ | } | |
| 5438 | |||
| 5439 | ✗ | bool enemy::fslide() | |
| 5440 | { | ||
| 5441 | ✗ | if(sclk==0 || (hp<=0 && !immortal)) | |
| 5442 | ✗ | return false; | |
| 5443 | |||
| 5444 | ✗ | if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true)) | |
| 5445 | { | ||
| 5446 | ✗ | sclk=0; | |
| 5447 | ✗ | return false; | |
| 5448 | } | ||
| 5449 | |||
| 5450 | ✗ | --sclk; | |
| 5451 | |||
| 5452 | ✗ | switch(sclk>>8) | |
| 5453 | { | ||
| 5454 | case up: | ||
| 5455 | ✗ | if(y<=16) | |
| 5456 | { | ||
| 5457 | ✗ | sclk=0; | |
| 5458 | ✗ | return false; | |
| 5459 | } | ||
| 5460 | |||
| 5461 | ✗ | break; | |
| 5462 | |||
| 5463 | case down: | ||
| 5464 | ✗ | if(y>=160) | |
| 5465 | { | ||
| 5466 | ✗ | sclk=0; | |
| 5467 | ✗ | return false; | |
| 5468 | } | ||
| 5469 | |||
| 5470 | ✗ | break; | |
| 5471 | |||
| 5472 | case left: | ||
| 5473 | ✗ | if(x<=16) | |
| 5474 | { | ||
| 5475 | ✗ | sclk=0; | |
| 5476 | ✗ | return false; | |
| 5477 | } | ||
| 5478 | |||
| 5479 | ✗ | break; | |
| 5480 | |||
| 5481 | case right: | ||
| 5482 | ✗ | if(x>=240) | |
| 5483 | { | ||
| 5484 | ✗ | sclk=0; | |
| 5485 | ✗ | return false; | |
| 5486 | } | ||
| 5487 | |||
| 5488 | ✗ | break; | |
| 5489 | } | ||
| 5490 | ✗ | hitdir = (sclk>>8); | |
| 5491 | ✗ | switch(sclk>>8) | |
| 5492 | { | ||
| 5493 | case up: | ||
| 5494 | ✗ | y-=4; | |
| 5495 | ✗ | break; | |
| 5496 | |||
| 5497 | case down: | ||
| 5498 | ✗ | y+=4; | |
| 5499 | ✗ | break; | |
| 5500 | |||
| 5501 | case left: | ||
| 5502 | ✗ | x-=4; | |
| 5503 | ✗ | break; | |
| 5504 | |||
| 5505 | case right: | ||
| 5506 | ✗ | x+=4; | |
| 5507 | ✗ | break; | |
| 5508 | } | ||
| 5509 | |||
| 5510 | ✗ | if(!canmove(sclk>>8,(zfix)0,spw_floater,true)) | |
| 5511 | { | ||
| 5512 | ✗ | switch(sclk>>8) | |
| 5513 | { | ||
| 5514 | case up: | ||
| 5515 | case down: | ||
| 5516 | ✗ | if((int32_t(y)&15) > 7) | |
| 5517 | ✗ | y=(int32_t(y)&0xF0)+16; | |
| 5518 | else | ||
| 5519 | ✗ | y=(int32_t(y)&0xF0); | |
| 5520 | |||
| 5521 | ✗ | break; | |
| 5522 | |||
| 5523 | case left: | ||
| 5524 | case right: | ||
| 5525 | ✗ | if((int32_t(x)&15) > 7) | |
| 5526 | ✗ | x=(int32_t(x)&0xF0)+16; | |
| 5527 | else | ||
| 5528 | ✗ | x=(int32_t(x)&0xF0); | |
| 5529 | |||
| 5530 | ✗ | break; | |
| 5531 | } | ||
| 5532 | |||
| 5533 | ✗ | sclk=0; | |
| 5534 | ✗ | clk3=0; | |
| 5535 | ✗ | } | |
| 5536 | |||
| 5537 | ✗ | if((sclk&255)==0) | |
| 5538 | ✗ | sclk=0; | |
| 5539 | |||
| 5540 | ✗ | return true; | |
| 5541 | ✗ | } | |
| 5542 | |||
| 5543 | ✗ | bool enemy::knockback(int32_t time, int32_t dir, int32_t speed) | |
| 5544 | { | ||
| 5545 | ✗ | if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies | |
| 5546 | ✗ | if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check | |
| 5547 | ✗ | bool ret = sprite::knockback(time, dir, speed); | |
| 5548 | ✗ | if(ret) sclk = 0; //kill engine knockback if interrupted | |
| 5549 | //! Perhaps also set hitdir here, if needed for timing? -Z | ||
| 5550 | ✗ | return ret; | |
| 5551 | ✗ | } | |
| 5552 | |||
| 5553 | 834284 | bool enemy::runKnockback() | |
| 5554 | { | ||
| 5555 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 834284 times.
|
834284 | if((script_knockback_clk&0xFF)==0) |
| 5556 | { | ||
| 5557 | 834284 | script_knockback_clk = 0; | |
| 5558 | 834284 | return false; | |
| 5559 | } | ||
| 5560 | ✗ | if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK) | |
| 5561 | { | ||
| 5562 | ✗ | return false; | |
| 5563 | } | ||
| 5564 | ✗ | int32_t move = script_knockback_speed; | |
| 5565 | ✗ | int32_t kb_dir = script_knockback_clk>>8; | |
| 5566 | ✗ | --script_knockback_clk; | |
| 5567 | |||
| 5568 | ✗ | while(move>0) | |
| 5569 | { | ||
| 5570 | ✗ | int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move); | |
| 5571 | ✗ | move -= thismove; | |
| 5572 | ✗ | hitdir = kb_dir; | |
| 5573 | ✗ | switch(kb_dir) | |
| 5574 | { | ||
| 5575 | case r_up: | ||
| 5576 | case l_up: | ||
| 5577 | case up: | ||
| 5578 | ✗ | y-=thismove; | |
| 5579 | ✗ | break; | |
| 5580 | |||
| 5581 | case r_down: | ||
| 5582 | case l_down: | ||
| 5583 | case down: | ||
| 5584 | ✗ | y+=thismove; | |
| 5585 | ✗ | break; | |
| 5586 | } | ||
| 5587 | ✗ | switch(kb_dir) | |
| 5588 | { | ||
| 5589 | case l_up: | ||
| 5590 | case l_down: | ||
| 5591 | case left: | ||
| 5592 | ✗ | x-=thismove; | |
| 5593 | ✗ | break; | |
| 5594 | |||
| 5595 | case r_up: | ||
| 5596 | case r_down: | ||
| 5597 | case right: | ||
| 5598 | ✗ | x+=thismove; | |
| 5599 | ✗ | break; | |
| 5600 | } | ||
| 5601 | ✗ | if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK)) | |
| 5602 | { | ||
| 5603 | ✗ | if(!canmove(kb_dir,(zfix)0,0,true)) | |
| 5604 | { | ||
| 5605 | ✗ | script_knockback_clk=0; | |
| 5606 | ✗ | clk3=0; | |
| 5607 | //Fix to grid | ||
| 5608 | ✗ | switch(kb_dir) | |
| 5609 | { | ||
| 5610 | case up: | ||
| 5611 | case down: | ||
| 5612 | ✗ | break; | |
| 5613 | default: | ||
| 5614 | ✗ | if(x < 0) | |
| 5615 | ✗ | x = 0; | |
| 5616 | ✗ | else if((int32_t(x)&15) > 7) | |
| 5617 | ✗ | x=(int32_t(x)&0xF0)+16; | |
| 5618 | else | ||
| 5619 | ✗ | x=(int32_t(x)&0xF0); | |
| 5620 | ✗ | break; | |
| 5621 | } | ||
| 5622 | ✗ | switch(kb_dir) | |
| 5623 | { | ||
| 5624 | case left: | ||
| 5625 | case right: | ||
| 5626 | ✗ | break; | |
| 5627 | default: | ||
| 5628 | ✗ | if(y < 0) | |
| 5629 | ✗ | y = 0; | |
| 5630 | ✗ | else if((int32_t(y)&15) > 7) | |
| 5631 | ✗ | y=(int32_t(y)&0xF0)+16; | |
| 5632 | else | ||
| 5633 | ✗ | y=(int32_t(y)&0xF0); | |
| 5634 | ✗ | break; | |
| 5635 | } | ||
| 5636 | ✗ | break; | |
| 5637 | } | ||
| 5638 | ✗ | } | |
| 5639 | else | ||
| 5640 | { | ||
| 5641 | ✗ | if(!scr_canplace(x,y,0,true)) | |
| 5642 | { | ||
| 5643 | ✗ | script_knockback_clk=0; | |
| 5644 | ✗ | clk3=0; | |
| 5645 | //Fix to grid | ||
| 5646 | ✗ | if (OFFGRID_ENEMY) | |
| 5647 | { | ||
| 5648 | ✗ | switch(kb_dir) | |
| 5649 | { | ||
| 5650 | case up: | ||
| 5651 | case down: | ||
| 5652 | ✗ | break; | |
| 5653 | default: | ||
| 5654 | ✗ | if(x < 0) | |
| 5655 | ✗ | x = 0; | |
| 5656 | ✗ | else if((int32_t(x)&7) > 3) | |
| 5657 | ✗ | x=(int32_t(x)&0xF8)+8; | |
| 5658 | else | ||
| 5659 | ✗ | x=(int32_t(x)&0xF8); | |
| 5660 | ✗ | break; | |
| 5661 | } | ||
| 5662 | ✗ | switch(kb_dir) | |
| 5663 | { | ||
| 5664 | case left: | ||
| 5665 | case right: | ||
| 5666 | ✗ | break; | |
| 5667 | default: | ||
| 5668 | ✗ | if(y < 0) | |
| 5669 | ✗ | y = 0; | |
| 5670 | ✗ | else if((int32_t(y)&7) > 3) | |
| 5671 | ✗ | y=(int32_t(y)&0xF8)+8; | |
| 5672 | else | ||
| 5673 | ✗ | y=(int32_t(y)&0xF8); | |
| 5674 | ✗ | break; | |
| 5675 | } | ||
| 5676 | ✗ | } | |
| 5677 | else | ||
| 5678 | { | ||
| 5679 | ✗ | switch(kb_dir) | |
| 5680 | { | ||
| 5681 | case up: | ||
| 5682 | case down: | ||
| 5683 | ✗ | break; | |
| 5684 | default: | ||
| 5685 | ✗ | if(x < 0) | |
| 5686 | ✗ | x = 0; | |
| 5687 | ✗ | else if((int32_t(x)&15) > 7) | |
| 5688 | ✗ | x=(int32_t(x)&0xF0)+16; | |
| 5689 | else | ||
| 5690 | ✗ | x=(int32_t(x)&0xF0); | |
| 5691 | ✗ | break; | |
| 5692 | } | ||
| 5693 | ✗ | switch(kb_dir) | |
| 5694 | { | ||
| 5695 | case left: | ||
| 5696 | case right: | ||
| 5697 | ✗ | break; | |
| 5698 | default: | ||
| 5699 | ✗ | if(y < 0) | |
| 5700 | ✗ | y = 0; | |
| 5701 | ✗ | else if((int32_t(y)&15) > 7) | |
| 5702 | ✗ | y=(int32_t(y)&0xF0)+16; | |
| 5703 | else | ||
| 5704 | ✗ | y=(int32_t(y)&0xF0); | |
| 5705 | ✗ | break; | |
| 5706 | } | ||
| 5707 | } | ||
| 5708 | ✗ | break; | |
| 5709 | } | ||
| 5710 | |||
| 5711 | } | ||
| 5712 | } | ||
| 5713 | ✗ | return true; | |
| 5714 | 834284 | } | |
| 5715 | // changes enemy's direction, checking restrictions | ||
| 5716 | // rate: 0 = no random changes, 16 = always random change | ||
| 5717 | // homing: 0 = none, 256 = always | ||
| 5718 | // grumble 0 = none, 4 = strongest appetite | ||
| 5719 | 13861 | void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special) | |
| 5720 | { | ||
| 5721 | 13861 | int32_t ndir=-1; | |
| 5722 | |||
| 5723 |
4/4✓ Branch 0 taken 4200 times.
✓ Branch 1 taken 9661 times.
✓ Branch 2 taken 2070 times.
✓ Branch 3 taken 2130 times.
|
13861 | if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join. |
| 5724 | { | ||
| 5725 | 2130 | int32_t i = Lwpns.idFirst(wBait); | |
| 5726 |
1/2✓ Branch 0 taken 2130 times.
✗ Branch 1 not taken.
|
2130 | if(i >= 0) //idfirst returns -1 if it can't find any |
| 5727 | { | ||
| 5728 | ✗ | weapon *w = (weapon*)Lwpns.spr(i); | |
| 5729 | ✗ | if (get_qr(qr_FIND_CLOSEST_BAIT)) | |
| 5730 | { | ||
| 5731 | int32_t currentrange; | ||
| 5732 | ✗ | if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y); | |
| 5733 | ✗ | else currentrange = -1; | |
| 5734 | ✗ | int curid = i; | |
| 5735 | ✗ | ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee | |
| 5736 | ✗ | for(; i<Lwpns.Count(); ++i) | |
| 5737 | { | ||
| 5738 | ✗ | weapon *lw = (weapon*)Lwpns.spr(i); | |
| 5739 | ✗ | if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0)) | |
| 5740 | { | ||
| 5741 | ✗ | currentrange = distance(x, y, lw->x, lw->y); | |
| 5742 | ✗ | curid = i; | |
| 5743 | ✗ | } | |
| 5744 | ✗ | } | |
| 5745 | ✗ | i = curid; | |
| 5746 | ✗ | if (currentrange == -1) i = -1; | |
| 5747 | ✗ | } | |
| 5748 | else | ||
| 5749 | { | ||
| 5750 | ✗ | if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1; | |
| 5751 | } | ||
| 5752 | ✗ | if (i >= 0) | |
| 5753 | { | ||
| 5754 | ✗ | int32_t bx = Lwpns.spr(i)->x; | |
| 5755 | ✗ | int32_t by = Lwpns.spr(i)->y; | |
| 5756 | |||
| 5757 | ✗ | if(abs(int32_t(y)-by)>14) | |
| 5758 | { | ||
| 5759 | ✗ | ndir = (by<y) ? up : down; | |
| 5760 | ✗ | if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir]; | |
| 5761 | ✗ | if(canmove(ndir,special,false)) | |
| 5762 | { | ||
| 5763 | ✗ | dir=ndir; | |
| 5764 | ✗ | return; | |
| 5765 | } | ||
| 5766 | ✗ | } | |
| 5767 | |||
| 5768 | ✗ | ndir = (bx<x) ? left : right; | |
| 5769 | ✗ | if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir]; | |
| 5770 | ✗ | if(canmove(ndir,special,false)) | |
| 5771 | { | ||
| 5772 | ✗ | dir=ndir; | |
| 5773 | ✗ | return; | |
| 5774 | } | ||
| 5775 | ✗ | } | |
| 5776 | ✗ | } | |
| 5777 | 2130 | } | |
| 5778 | |||
| 5779 |
2/2✓ Branch 0 taken 9084 times.
✓ Branch 1 taken 4777 times.
|
13861 | if((zc_oldrand()&255)<abs(newhoming)) |
| 5780 | { | ||
| 5781 | 4777 | ndir = lined_up(8,false); | |
| 5782 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4777 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4777 | if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir]; |
| 5783 |
4/4✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 3515 times.
✓ Branch 2 taken 117 times.
✓ Branch 3 taken 1145 times.
|
4777 | if(ndir>=0 && canmove(ndir,special,false)) |
| 5784 | { | ||
| 5785 | 1145 | dir=ndir; | |
| 5786 | 1145 | return; | |
| 5787 | } | ||
| 5788 | 3632 | } | |
| 5789 | |||
| 5790 | 12716 | int32_t i=0; | |
| 5791 | |||
| 5792 |
2/2✓ Branch 0 taken 47 times.
✓ Branch 1 taken 26652 times.
|
26699 | for(; i<32; i++) |
| 5793 | { | ||
| 5794 | 26652 | int32_t r=zc_oldrand(); | |
| 5795 | |||
| 5796 |
2/2✓ Branch 0 taken 7542 times.
✓ Branch 1 taken 19110 times.
|
26652 | if((r&15)<newrate) |
| 5797 | 7542 | ndir=(r>>4)&3; | |
| 5798 | else | ||
| 5799 | 19110 | ndir=dir; | |
| 5800 | |||
| 5801 |
2/2✓ Branch 0 taken 13983 times.
✓ Branch 1 taken 12669 times.
|
26652 | if(canmove(ndir,special,false)) |
| 5802 | 12669 | break; | |
| 5803 | 13983 | } | |
| 5804 | |||
| 5805 |
2/2✓ Branch 0 taken 12669 times.
✓ Branch 1 taken 47 times.
|
12721 | if(i==32) |
| 5806 | { | ||
| 5807 |
2/2✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
|
111 | for(ndir=0; ndir<4; ndir++) |
| 5808 | { | ||
| 5809 |
2/2✓ Branch 0 taken 64 times.
✓ Branch 1 taken 42 times.
|
106 | if(canmove(ndir,special,false)) |
| 5810 | 42 | goto ok; | |
| 5811 | 64 | } | |
| 5812 | |||
| 5813 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1 |
| 5814 | //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi | ||
| 5815 | 5 | } | |
| 5816 | |||
| 5817 | ok: | ||
| 5818 | 12716 | dir = ndir; | |
| 5819 | 13861 | } | |
| 5820 | |||
| 5821 | 20 | void enemy::newdir() | |
| 5822 | { | ||
| 5823 | 20 | newdir(4,0,spw_none); | |
| 5824 | 20 | } | |
| 5825 | |||
| 5826 | ✗ | zfix enemy::distance_left() | |
| 5827 | { | ||
| 5828 | ✗ | int32_t a2=x.getInt(); | |
| 5829 | ✗ | int32_t b2=y.getInt(); | |
| 5830 | |||
| 5831 | ✗ | switch(dir) | |
| 5832 | { | ||
| 5833 | case up: | ||
| 5834 | ✗ | return (zfix)(b2&0xF); | |
| 5835 | |||
| 5836 | case down: | ||
| 5837 | ✗ | return (zfix)(16-(b2&0xF)); | |
| 5838 | |||
| 5839 | case left: | ||
| 5840 | ✗ | return (zfix)(a2&0xF); | |
| 5841 | |||
| 5842 | case right: | ||
| 5843 | ✗ | return (zfix)(16-(a2&0xF)); | |
| 5844 | } | ||
| 5845 | |||
| 5846 | ✗ | return (zfix)0; | |
| 5847 | ✗ | } | |
| 5848 | |||
| 5849 | // keeps walking around | ||
| 5850 | 4336 | void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special) | |
| 5851 | { | ||
| 5852 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4336 times.
|
4336 | if(slide()) |
| 5853 | ✗ | return; | |
| 5854 | |||
| 5855 |
8/12✓ Branch 0 taken 4225 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 4225 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4170 times.
✓ Branch 5 taken 55 times.
✓ Branch 6 taken 4170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4170 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4170 times.
|
4336 | if(clk<0 || dying || stunclk || watch || ceiling || frozenclock ) |
| 5856 | 166 | return; | |
| 5857 | |||
| 5858 |
2/2✓ Branch 0 taken 236 times.
✓ Branch 1 taken 3934 times.
|
4170 | if(clk3<=0) |
| 5859 | { | ||
| 5860 | 236 | fix_coords(true); | |
| 5861 | 236 | newdir(newrate,newhoming,special); | |
| 5862 | |||
| 5863 |
1/2✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
|
236 | if(step==0) |
| 5864 | ✗ | clk3=0; | |
| 5865 | else | ||
| 5866 | 236 | clk3=int32_t(16.0/step); | |
| 5867 | 236 | } | |
| 5868 |
1/2✓ Branch 0 taken 3934 times.
✗ Branch 1 not taken.
|
3934 | else if(scored) |
| 5869 | { | ||
| 5870 | ✗ | dir^=1; | |
| 5871 | ✗ | if (step != 0) clk3=int32_t(16.0/step)-clk3; | |
| 5872 | ✗ | else clk3=32767; | |
| 5873 | ✗ | } | |
| 5874 | |||
| 5875 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4170 times.
|
4170 | if (step != 0) --clk3; |
| 5876 | 4170 | move(step); | |
| 5877 | 4336 | } | |
| 5878 | |||
| 5879 | ✗ | void enemy::constant_walk() | |
| 5880 | { | ||
| 5881 | ✗ | constant_walk(4,0,spw_none); | |
| 5882 | ✗ | } | |
| 5883 | |||
| 5884 | 234 | int32_t enemy::pos(int32_t newx,int32_t newy) | |
| 5885 | { | ||
| 5886 | 234 | return (newy<<8)+newx; | |
| 5887 | } | ||
| 5888 | |||
| 5889 | // for variable step rates | ||
| 5890 | 2756 | void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special) | |
| 5891 | { | ||
| 5892 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2756 times.
|
2756 | if(slide()) |
| 5893 | ✗ | return; | |
| 5894 | |||
| 5895 |
7/14✓ Branch 0 taken 2756 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2756 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2756 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2756 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2756 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2756 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2756 times.
✗ Branch 13 not taken.
|
2756 | if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock ) |
| 5896 | ✗ | return; | |
| 5897 | |||
| 5898 | 2756 | zfix dx = (zfix)0; | |
| 5899 | 2756 | zfix dy = (zfix)0; | |
| 5900 | |||
| 5901 |
4/9✓ Branch 0 taken 421 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 1295 times.
✓ Branch 3 taken 836 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
2756 | switch(dir) |
| 5902 | { | ||
| 5903 | case 8: | ||
| 5904 | case up: | ||
| 5905 | 421 | dy-=step; | |
| 5906 | 421 | break; | |
| 5907 | |||
| 5908 | case 12: | ||
| 5909 | case down: | ||
| 5910 | 204 | dy+=step; | |
| 5911 | 204 | break; | |
| 5912 | |||
| 5913 | case 14: | ||
| 5914 | case left: | ||
| 5915 | 1295 | dx-=step; | |
| 5916 | 1295 | break; | |
| 5917 | |||
| 5918 | case 10: | ||
| 5919 | case right: | ||
| 5920 | 836 | dx+=step; | |
| 5921 | 836 | break; | |
| 5922 | |||
| 5923 | case 15: | ||
| 5924 | case l_up: | ||
| 5925 | ✗ | dx-=step; | |
| 5926 | ✗ | dy-=step; | |
| 5927 | ✗ | break; | |
| 5928 | |||
| 5929 | case 9: | ||
| 5930 | case r_up: | ||
| 5931 | ✗ | dx+=step; | |
| 5932 | ✗ | dy-=step; | |
| 5933 | ✗ | break; | |
| 5934 | |||
| 5935 | case 13: | ||
| 5936 | case l_down: | ||
| 5937 | ✗ | dx-=step; | |
| 5938 | ✗ | dy+=step; | |
| 5939 | ✗ | break; | |
| 5940 | |||
| 5941 | case 11: | ||
| 5942 | case r_down: | ||
| 5943 | ✗ | dx+=step; | |
| 5944 | ✗ | dy+=step; | |
| 5945 | ✗ | break; | |
| 5946 | } | ||
| 5947 | |||
| 5948 |
8/8✓ Branch 0 taken 739 times.
✓ Branch 1 taken 2017 times.
✓ Branch 2 taken 151 times.
✓ Branch 3 taken 588 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 68 times.
✓ Branch 6 taken 2673 times.
✓ Branch 7 taken 83 times.
|
2756 | if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) || |
| 5949 | 2673 | m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir)) | |
| 5950 | { | ||
| 5951 | 83 | fix_coords(); | |
| 5952 | 83 | newdir(newrate,newhoming,special); | |
| 5953 | 83 | clk3=pos(x,y); | |
| 5954 | 83 | } | |
| 5955 | |||
| 5956 | 2756 | move(step); | |
| 5957 | 2756 | } | |
| 5958 | |||
| 5959 | // pauses for a while after it makes a complete move (to a new square) | ||
| 5960 | 341416 | void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt) | |
| 5961 | { | ||
| 5962 |
4/4✓ Branch 0 taken 2387 times.
✓ Branch 1 taken 339029 times.
✓ Branch 2 taken 2143 times.
✓ Branch 3 taken 244 times.
|
341416 | if(sclk && clk2) |
| 5963 | { | ||
| 5964 | 244 | clk3=0; | |
| 5965 | 244 | } | |
| 5966 | |||
| 5967 |
10/14✓ Branch 0 taken 339465 times.
✓ Branch 1 taken 1951 times.
✓ Branch 2 taken 339465 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 339465 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 332505 times.
✓ Branch 7 taken 6960 times.
✓ Branch 8 taken 327252 times.
✓ Branch 9 taken 5253 times.
✓ Branch 10 taken 327252 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 327252 times.
|
341416 | if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock) |
| 5968 | { | ||
| 5969 | 14164 | return; | |
| 5970 | } | ||
| 5971 | |||
| 5972 |
2/2✓ Branch 0 taken 51614 times.
✓ Branch 1 taken 275638 times.
|
327252 | if(clk2>0) |
| 5973 | { | ||
| 5974 | 51614 | --clk2; | |
| 5975 | 51614 | return; | |
| 5976 | } | ||
| 5977 | |||
| 5978 |
2/2✓ Branch 0 taken 11715 times.
✓ Branch 1 taken 263923 times.
|
275638 | if(clk3<=0) |
| 5979 | { | ||
| 5980 | 11715 | fix_coords(true); | |
| 5981 | 11715 | newdir(newrate,newhoming,special); | |
| 5982 | 11715 | clk3=int32_t(16.0/step); | |
| 5983 |
1/2✓ Branch 0 taken 11715 times.
✗ Branch 1 not taken.
|
11715 | if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break. |
| 5984 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11715 times.
|
11715 | if(clk2<0) |
| 5985 | { | ||
| 5986 | ✗ | clk2=0; | |
| 5987 | ✗ | } | |
| 5988 |
2/2✓ Branch 0 taken 1549 times.
✓ Branch 1 taken 10166 times.
|
11715 | else if((zc_oldrand()&15)<newhrate) |
| 5989 | { | ||
| 5990 | 1549 | clk2=haltcnt; | |
| 5991 | 1549 | return; | |
| 5992 | } | ||
| 5993 | 10166 | } | |
| 5994 |
2/2✓ Branch 0 taken 263862 times.
✓ Branch 1 taken 61 times.
|
263923 | else if(scored) |
| 5995 | { | ||
| 5996 | 61 | dir^=1; | |
| 5997 | |||
| 5998 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
|
61 | if (step != 0) clk3=int32_t(16.0/step)-clk3; |
| 5999 | ✗ | else clk3=32767; | |
| 6000 | 61 | } | |
| 6001 | |||
| 6002 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 274089 times.
|
274089 | if (step != 0) --clk3; |
| 6003 | 274089 | move(step); | |
| 6004 | 341416 | } | |
| 6005 | |||
| 6006 | // 8-directional movement, aligns to 8 pixels | ||
| 6007 | ✗ | void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special) | |
| 6008 | { | ||
| 6009 | ✗ | if(clk<0 || dying || stunclk || watch || ceiling || frozenclock) | |
| 6010 | ✗ | return; | |
| 6011 | |||
| 6012 | ✗ | if(clk3<=0) | |
| 6013 | { | ||
| 6014 | ✗ | newdir_8(newrate,newhoming,special); | |
| 6015 | ✗ | clk3=int32_t(8.0/step); | |
| 6016 | ✗ | if (step == 0) clk3 = 32767; | |
| 6017 | ✗ | } | |
| 6018 | |||
| 6019 | ✗ | if (step != 0) --clk3; | |
| 6020 | ✗ | move(step); | |
| 6021 | ✗ | } | |
| 6022 | // 8-directional movement, aligns to 8 pixels | ||
| 6023 | 1098 | void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special) | |
| 6024 | { | ||
| 6025 |
6/12✓ Branch 0 taken 1098 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1098 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1098 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1098 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1098 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1098 times.
|
1098 | if(clk<0 || dying || stunclk || watch || ceiling || frozenclock) |
| 6026 | ✗ | return; | |
| 6027 | |||
| 6028 |
2/2✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 74 times.
|
1098 | if(clk3<=0) |
| 6029 | { | ||
| 6030 | 74 | newdir_8(newrate,newhoming,special); | |
| 6031 | 74 | clk3=int32_t(8.0/step); | |
| 6032 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
|
74 | if (step == 0) clk3 = 32767; |
| 6033 | 74 | } | |
| 6034 | |||
| 6035 |
1/2✓ Branch 0 taken 1098 times.
✗ Branch 1 not taken.
|
1098 | if (step != 0) --clk3; |
| 6036 | 1098 | move(step); | |
| 6037 | 1098 | } | |
| 6038 | |||
| 6039 | ✗ | void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt) | |
| 6040 | { | ||
| 6041 | ✗ | if(clk<0 || dying || stunclk || watch || frozenclock) | |
| 6042 | ✗ | return; | |
| 6043 | |||
| 6044 | ✗ | if(!canmove(dir,step,special,false)) | |
| 6045 | ✗ | clk3=0; | |
| 6046 | |||
| 6047 | ✗ | if(clk2>0) | |
| 6048 | { | ||
| 6049 | ✗ | --clk2; | |
| 6050 | ✗ | return; | |
| 6051 | } | ||
| 6052 | |||
| 6053 | ✗ | if(clk3<=0) | |
| 6054 | { | ||
| 6055 | ✗ | newdir_8(newrate,newhoming,special); | |
| 6056 | ✗ | clk3=newclk; | |
| 6057 | |||
| 6058 | ✗ | if(clk2<0) | |
| 6059 | { | ||
| 6060 | ✗ | clk2=0; | |
| 6061 | ✗ | } | |
| 6062 | ✗ | else if((zc_oldrand()&15)<newhrate) | |
| 6063 | { | ||
| 6064 | ✗ | newdir_8(newrate,newhoming,special); | |
| 6065 | ✗ | clk2=haltcnt; | |
| 6066 | ✗ | return; | |
| 6067 | } | ||
| 6068 | ✗ | } | |
| 6069 | |||
| 6070 | ✗ | --clk3; | |
| 6071 | ✗ | move(step); | |
| 6072 | ✗ | } | |
| 6073 | |||
| 6074 | // 8-directional movement, no alignment | ||
| 6075 | 100906 | void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special) | |
| 6076 | { | ||
| 6077 |
8/12✓ Branch 0 taken 93967 times.
✓ Branch 1 taken 6939 times.
✓ Branch 2 taken 93967 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93389 times.
✓ Branch 5 taken 578 times.
✓ Branch 6 taken 93389 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 93389 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93389 times.
|
100906 | if(clk<0 || dying || stunclk || watch || ceiling || frozenclock) |
| 6078 | 7517 | return; | |
| 6079 | |||
| 6080 |
2/2✓ Branch 0 taken 92921 times.
✓ Branch 1 taken 468 times.
|
93389 | if(!canmove(dir,step,special,false)) |
| 6081 | 468 | clk3=0; | |
| 6082 | |||
| 6083 |
2/2✓ Branch 0 taken 81352 times.
✓ Branch 1 taken 12037 times.
|
93389 | if(clk3<=0) |
| 6084 | { | ||
| 6085 | 12037 | newdir_8(newrate,newhoming,special); | |
| 6086 | 12037 | clk3=newclk; | |
| 6087 | 12037 | } | |
| 6088 | |||
| 6089 | 93389 | --clk3; | |
| 6090 | 93389 | move(step); | |
| 6091 | 100906 | } | |
| 6092 | |||
| 6093 | // same as above but with variable enemy size | ||
| 6094 | 1936 | void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2) | |
| 6095 | { | ||
| 6096 |
7/12✓ Branch 0 taken 1891 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 1891 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1891 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1891 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1891 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1891 times.
|
1936 | if(clk<0 || dying || stunclk || watch || ceiling || frozenclock) |
| 6097 | 45 | return; | |
| 6098 | |||
| 6099 |
2/2✓ Branch 0 taken 1869 times.
✓ Branch 1 taken 22 times.
|
1891 | if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false)) |
| 6100 | 22 | clk3=0; | |
| 6101 | |||
| 6102 |
2/2✓ Branch 0 taken 1762 times.
✓ Branch 1 taken 129 times.
|
1891 | if(clk3<=0) |
| 6103 | { | ||
| 6104 | 129 | newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2); | |
| 6105 | 129 | clk3=newclk; | |
| 6106 | 129 | } | |
| 6107 | |||
| 6108 | 1891 | --clk3; | |
| 6109 | 1891 | move(step); | |
| 6110 | 1936 | } | |
| 6111 | |||
| 6112 | // the variable speed floater movement | ||
| 6113 | // ms is max speed | ||
| 6114 | // ss is step speed | ||
| 6115 | // s is step count | ||
| 6116 | // p is pause count | ||
| 6117 | // g is graduality :) | ||
| 6118 | //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17); | ||
| 6119 | 84025 | void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g) | |
| 6120 | { | ||
| 6121 | 84025 | ++clk2; | |
| 6122 | 84025 | byte over_pit = overpit(this); | |
| 6123 | |||
| 6124 |
3/4✓ Branch 0 taken 1230 times.
✓ Branch 1 taken 82795 times.
✓ Branch 2 taken 1230 times.
✗ Branch 3 not taken.
|
84025 | if(dmisc1 && over_pit) p = 0; |
| 6125 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 54739 times.
✓ Branch 3 taken 26581 times.
✓ Branch 4 taken 2064 times.
|
84025 | switch(movestatus) |
| 6126 | { | ||
| 6127 | //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and | ||
| 6128 | //! if the conditions prevent it, we jump back to case 2. | ||
| 6129 | case 0: // paused | ||
| 6130 |
2/2✓ Branch 0 taken 638 times.
✓ Branch 1 taken 3 times.
|
641 | if(clk2>=p) |
| 6131 | { | ||
| 6132 | 3 | movestatus=1; | |
| 6133 | 3 | clk2=0; | |
| 6134 | 3 | } | |
| 6135 | |||
| 6136 | 641 | break; | |
| 6137 | |||
| 6138 | case 1: // speeding up | ||
| 6139 |
1/2✓ Branch 0 taken 54739 times.
✗ Branch 1 not taken.
|
54739 | if (s >= 0) |
| 6140 | { | ||
| 6141 |
2/2✓ Branch 0 taken 54491 times.
✓ Branch 1 taken 248 times.
|
54739 | if(clk2<g*s) |
| 6142 | { | ||
| 6143 |
2/2✓ Branch 0 taken 51030 times.
✓ Branch 1 taken 3461 times.
|
54491 | if(!((clk2-1)%g)) |
| 6144 | 3461 | step+=ss; | |
| 6145 | 54491 | } | |
| 6146 | else | ||
| 6147 | { | ||
| 6148 | 248 | movestatus=2; | |
| 6149 | 248 | clk2=0; | |
| 6150 | } | ||
| 6151 | 54739 | } | |
| 6152 | else | ||
| 6153 | { | ||
| 6154 | ✗ | if(step < ms) | |
| 6155 | { | ||
| 6156 | ✗ | if(!((clk2-1)%g)) | |
| 6157 | { | ||
| 6158 | ✗ | step+=ss; | |
| 6159 | ✗ | if (step >= ms) step = ms; | |
| 6160 | ✗ | } | |
| 6161 | ✗ | } | |
| 6162 | else | ||
| 6163 | { | ||
| 6164 | ✗ | step = ms; | |
| 6165 | ✗ | movestatus=2; | |
| 6166 | ✗ | clk2=0; | |
| 6167 | } | ||
| 6168 | } | ||
| 6169 | |||
| 6170 | 54739 | break; | |
| 6171 | |||
| 6172 | case 2: // normal | ||
| 6173 | 26581 | step=ms; | |
| 6174 | |||
| 6175 |
6/8✗ Branch 0 not taken.
✓ Branch 1 taken 26581 times.
✓ Branch 2 taken 9041 times.
✓ Branch 3 taken 17540 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17540 times.
✓ Branch 6 taken 17517 times.
✓ Branch 7 taken 23 times.
|
26581 | if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768))) |
| 6176 | { | ||
| 6177 |
1/2✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
|
23 | if (s >= 0) step=ss*s; |
| 6178 | ✗ | else step=ms; | |
| 6179 | 23 | movestatus=3; | |
| 6180 | 23 | clk2=0; | |
| 6181 | 23 | } | |
| 6182 | |||
| 6183 | 26581 | break; | |
| 6184 | |||
| 6185 | case 3: // slowing down | ||
| 6186 |
1/2✓ Branch 0 taken 2064 times.
✗ Branch 1 not taken.
|
2064 | if (s >= 0) |
| 6187 | { | ||
| 6188 |
2/2✓ Branch 0 taken 2057 times.
✓ Branch 1 taken 7 times.
|
2064 | if(clk2<=g*s) |
| 6189 | { | ||
| 6190 | { //don't slow down over pits | ||
| 6191 | |||
| 6192 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2045 times.
|
2057 | if(over_pit) |
| 6193 | { | ||
| 6194 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if(dmisc1) |
| 6195 | { | ||
| 6196 | ✗ | step=ms; | |
| 6197 | ✗ | } | |
| 6198 | 12 | } | |
| 6199 | else //can slow down | ||
| 6200 | { | ||
| 6201 |
3/4✓ Branch 0 taken 124 times.
✓ Branch 1 taken 1921 times.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
|
2045 | if(!(clk2%g) && !dmisc1) |
| 6202 | 124 | step-=ss; | |
| 6203 | } | ||
| 6204 | } | ||
| 6205 | |||
| 6206 | |||
| 6207 | 2057 | } | |
| 6208 | else | ||
| 6209 | { | ||
| 6210 | //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them | ||
| 6211 | //this doesn't help keese, as they have a z of 0. | ||
| 6212 | //they always nee to run this check. | ||
| 6213 | { | ||
| 6214 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if(over_pit &&!dmisc1) |
| 6215 | { | ||
| 6216 | ✗ | --clk2; //if over a pit, don't land, and revert clock change | |
| 6217 | ✗ | } | |
| 6218 | else //can land safely | ||
| 6219 | { | ||
| 6220 | 7 | movestatus=0; | |
| 6221 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if(dmisc1&&!over_pit) |
| 6222 | ✗ | step=0; | |
| 6223 | 7 | clk2=0; | |
| 6224 | } | ||
| 6225 | } | ||
| 6226 | |||
| 6227 | } | ||
| 6228 | 2064 | } | |
| 6229 | else | ||
| 6230 | { | ||
| 6231 | ✗ | if(step > 0) | |
| 6232 | { | ||
| 6233 | ✗ | if(over_pit) | |
| 6234 | { | ||
| 6235 | ✗ | if(dmisc1) | |
| 6236 | { | ||
| 6237 | ✗ | step=ms; | |
| 6238 | ✗ | } | |
| 6239 | ✗ | } | |
| 6240 | else //can slow down | ||
| 6241 | { | ||
| 6242 | ✗ | if(!(clk2%g)) | |
| 6243 | ✗ | step-=ss; | |
| 6244 | } | ||
| 6245 | ✗ | } | |
| 6246 | else | ||
| 6247 | { | ||
| 6248 | //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them | ||
| 6249 | //this doesn't help keese, as they have a z of 0. | ||
| 6250 | //they always nee to run this check. | ||
| 6251 | ✗ | if(over_pit) | |
| 6252 | { | ||
| 6253 | ✗ | step+=ss; //if over a pit, don't land, and revert clock change | |
| 6254 | ✗ | } | |
| 6255 | else //can land safely | ||
| 6256 | { | ||
| 6257 | ✗ | movestatus=0; | |
| 6258 | ✗ | step=0; | |
| 6259 | ✗ | clk2=0; | |
| 6260 | } | ||
| 6261 | } | ||
| 6262 | } | ||
| 6263 | |||
| 6264 | 2064 | break; | |
| 6265 | } | ||
| 6266 | |||
| 6267 |
2/2✓ Branch 0 taken 26806 times.
✓ Branch 1 taken 57219 times.
|
84025 | variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater); |
| 6268 | 84025 | } | |
| 6269 | |||
| 6270 | ✗ | void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s) | |
| 6271 | { | ||
| 6272 | ✗ | floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32); | |
| 6273 | ✗ | } | |
| 6274 | |||
| 6275 | // Checks if enemy is lined up with Hero. If so, returns direction Hero is | ||
| 6276 | // at as compared to enemy. Returns -1 if not lined up. Range is inclusive. | ||
| 6277 | 16021 | int32_t enemy::lined_up(int32_t range, bool dir8) | |
| 6278 | { | ||
| 6279 | 16021 | int32_t lx = Hero.getX(); | |
| 6280 | 16021 | int32_t ly = Hero.getY(); | |
| 6281 | |||
| 6282 |
2/2✓ Branch 0 taken 544 times.
✓ Branch 1 taken 15477 times.
|
16021 | if(abs(lx-int32_t(x))<=range) |
| 6283 | { | ||
| 6284 |
2/2✓ Branch 0 taken 219 times.
✓ Branch 1 taken 325 times.
|
544 | if(ly<y) |
| 6285 | { | ||
| 6286 | 219 | return up; | |
| 6287 | } | ||
| 6288 | |||
| 6289 | 325 | return down; | |
| 6290 | } | ||
| 6291 | |||
| 6292 |
2/2✓ Branch 0 taken 984 times.
✓ Branch 1 taken 14493 times.
|
15477 | if(abs(ly-int32_t(y))<=range) |
| 6293 | { | ||
| 6294 |
2/2✓ Branch 0 taken 487 times.
✓ Branch 1 taken 497 times.
|
984 | if(lx<x) |
| 6295 | { | ||
| 6296 | 487 | return left; | |
| 6297 | } | ||
| 6298 | |||
| 6299 | 497 | return right; | |
| 6300 | } | ||
| 6301 | |||
| 6302 |
2/2✓ Branch 0 taken 4670 times.
✓ Branch 1 taken 9823 times.
|
14493 | if(dir8) |
| 6303 | { | ||
| 6304 |
2/2✓ Branch 0 taken 4326 times.
✓ Branch 1 taken 5497 times.
|
9823 | if(abs(lx-x)-abs(ly-y)<=range) |
| 6305 | //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo | ||
| 6306 | { | ||
| 6307 |
2/2✓ Branch 0 taken 2312 times.
✓ Branch 1 taken 2014 times.
|
4326 | if(ly<y) |
| 6308 | { | ||
| 6309 |
2/2✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 1006 times.
|
2312 | if(lx<x) |
| 6310 | { | ||
| 6311 | 1306 | return l_up; | |
| 6312 | } | ||
| 6313 | else | ||
| 6314 | { | ||
| 6315 | 1006 | return r_up; | |
| 6316 | } | ||
| 6317 | } | ||
| 6318 | else | ||
| 6319 | { | ||
| 6320 |
2/2✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 959 times.
|
2014 | if(lx<x) |
| 6321 | { | ||
| 6322 | 959 | return l_down; | |
| 6323 | } | ||
| 6324 | else | ||
| 6325 | { | ||
| 6326 | 1055 | return r_down; | |
| 6327 | } | ||
| 6328 | } | ||
| 6329 | } | ||
| 6330 | 5497 | } | |
| 6331 | |||
| 6332 | 10167 | return -1; | |
| 6333 | 16021 | } | |
| 6334 | |||
| 6335 | // returns true if Hero is within 'range' pixels of the enemy | ||
| 6336 | 331 | bool enemy::HeroInRange(int32_t range) | |
| 6337 | { | ||
| 6338 | 331 | int32_t lx = Hero.getX(); | |
| 6339 | 331 | int32_t ly = Hero.getY(); | |
| 6340 |
2/2✓ Branch 0 taken 262 times.
✓ Branch 1 taken 69 times.
|
331 | return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range; |
| 6341 | } | ||
| 6342 | |||
| 6343 | // place the enemy in line with Hero (red wizzrobes) | ||
| 6344 | 86 | void enemy::place_on_axis(bool floater, bool solid_ok) | |
| 6345 | { | ||
| 6346 |
6/6✓ Branch 0 taken 4 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 78 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 74 times.
|
86 | int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208); |
| 6347 |
6/6✓ Branch 0 taken 7 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 73 times.
|
86 | int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128); |
| 6348 | 86 | int32_t pos2=zc_oldrand()%23; | |
| 6349 | 86 | int32_t tried=0; | |
| 6350 | 86 | bool last_resort,placed=false; | |
| 6351 | |||
| 6352 | |||
| 6353 | 86 | do | |
| 6354 | { | ||
| 6355 |
2/2✓ Branch 0 taken 91 times.
✓ Branch 1 taken 73 times.
|
164 | if(pos2<14) |
| 6356 | { | ||
| 6357 | 91 | x=(pos2<<4)+16; | |
| 6358 | 91 | y=ly; | |
| 6359 | 91 | } | |
| 6360 | else | ||
| 6361 | { | ||
| 6362 | 73 | x=lx; | |
| 6363 | 73 | y=((pos2-14)<<4)+16; | |
| 6364 | } | ||
| 6365 | |||
| 6366 | // Don't commit to a last resort if position is out of bounds. | ||
| 6367 |
6/6✓ Branch 0 taken 159 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 152 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 142 times.
|
164 | last_resort= !(x<32 || y<32 || x>=224 || y>=144); |
| 6368 | |||
| 6369 |
4/4✓ Branch 0 taken 84 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 213 times.
✓ Branch 3 taken 129 times.
|
164 | if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16) |
| 6370 | { | ||
| 6371 | // Red Wizzrobes should be able to appear on water, but not other | ||
| 6372 | // solid combos; however, they could appear on solid combos in 2.10, | ||
| 6373 | // and some quests depend on that. | ||
| 6374 |
4/4✓ Branch 0 taken 130 times.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 86 times.
|
293 | if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir)) |
| 6375 | 293 | && !flyerblocked(x,y,floater ? spw_floater : spw_door)) | |
| 6376 | 86 | placed=true; | |
| 6377 | 293 | } | |
| 6378 | |||
| 6379 |
3/6✓ Branch 0 taken 78 times.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
268 | if(!placed && tried>=22 && last_resort) |
| 6380 | { | ||
| 6381 | ✗ | placed=true; | |
| 6382 | ✗ | } | |
| 6383 | |||
| 6384 | 268 | ++tried; | |
| 6385 | 268 | pos2=(pos2+3)%23; | |
| 6386 |
2/2✓ Branch 0 taken 78 times.
✓ Branch 1 taken 190 times.
|
268 | } |
| 6387 | 268 | while(!placed); | |
| 6388 | |||
| 6389 |
2/2✓ Branch 0 taken 154 times.
✓ Branch 1 taken 36 times.
|
190 | if(y==ly) |
| 6390 | 154 | dir=(x<lx)?right:left; | |
| 6391 | else | ||
| 6392 | 36 | dir=(y<ly)?down:up; | |
| 6393 | |||
| 6394 | 190 | clk2=tried; | |
| 6395 | 190 | } | |
| 6396 | |||
| 6397 | 182625 | int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4) | |
| 6398 | { | ||
| 6399 | 182625 | int32_t t = o_tile; | |
| 6400 | 182625 | int32_t b = o_tile; | |
| 6401 | |||
| 6402 | // Darknuts, but also Wizzrobes and Wallmasters | ||
| 6403 |
3/4✓ Branch 0 taken 31624 times.
✓ Branch 1 taken 145801 times.
✓ Branch 2 taken 5200 times.
✗ Branch 3 not taken.
|
182625 | switch(family) |
| 6404 | { | ||
| 6405 | case eeWALK: | ||
| 6406 |
5/6✓ Branch 0 taken 2330 times.
✓ Branch 1 taken 143471 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 430 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1900 times.
|
145801 | if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation) |
| 6407 | { | ||
| 6408 | 1900 | tile=s_tile; | |
| 6409 | 1900 | t=s_tile; | |
| 6410 | 1900 | b=s_tile; | |
| 6411 | 1900 | } | |
| 6412 | |||
| 6413 | 145801 | break; | |
| 6414 | |||
| 6415 | case eeTRAP: | ||
| 6416 |
4/6✓ Branch 0 taken 2872 times.
✓ Branch 1 taken 2328 times.
✓ Branch 2 taken 2872 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2872 times.
|
5200 | if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure |
| 6417 | { | ||
| 6418 | 2872 | tile=s_tile; | |
| 6419 | 2872 | t=s_tile; | |
| 6420 | 2872 | b=s_tile; | |
| 6421 | 2872 | } | |
| 6422 | |||
| 6423 | 5200 | break; | |
| 6424 | |||
| 6425 | case eeSPINTILE: | ||
| 6426 | ✗ | if(misc>=96 && do_animation) | |
| 6427 | { | ||
| 6428 | ✗ | tile=o_tile+frames*ndir; | |
| 6429 | ✗ | t=tile; | |
| 6430 | ✗ | } | |
| 6431 | |||
| 6432 | ✗ | break; | |
| 6433 | } | ||
| 6434 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 182625 times.
|
182625 | if ( do_animation ) |
| 6435 | { | ||
| 6436 |
4/6✓ Branch 0 taken 18584 times.
✓ Branch 1 taken 164041 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3057 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 160984 times.
|
182625 | if(ndir!=0) switch(frames) |
| 6437 | { | ||
| 6438 | case 2: | ||
| 6439 | 3057 | tiledir_small(dir,ndir==4); | |
| 6440 | 3057 | break; | |
| 6441 | |||
| 6442 | case 3: | ||
| 6443 | ✗ | tiledir_three(dir); | |
| 6444 | ✗ | break; | |
| 6445 | |||
| 6446 | case 4: | ||
| 6447 | 160984 | tiledir(dir,ndir==4); | |
| 6448 | 160984 | break; | |
| 6449 | 164041 | } | |
| 6450 | |||
| 6451 |
2/2✓ Branch 0 taken 145801 times.
✓ Branch 1 taken 36824 times.
|
182625 | if(family==eeWALK) |
| 6452 |
6/6✓ Branch 0 taken 145465 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 110644 times.
✓ Branch 3 taken 35157 times.
✓ Branch 4 taken 35077 times.
✓ Branch 5 taken 80 times.
|
145801 | tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1); |
| 6453 | else | ||
| 6454 | 36824 | tile+=f4; | |
| 6455 | 182625 | } | |
| 6456 | 182625 | return b; | |
| 6457 | } | ||
| 6458 | |||
| 6459 | ✗ | void enemy::tiledir_three(int32_t ndir) | |
| 6460 | { | ||
| 6461 | ✗ | if ( !do_animation ) return; | |
| 6462 | ✗ | flip=0; | |
| 6463 | |||
| 6464 | ✗ | switch(ndir) | |
| 6465 | { | ||
| 6466 | case right: | ||
| 6467 | ✗ | tile+=3; | |
| 6468 | [[fallthrough]]; | ||
| 6469 | |||
| 6470 | case left: | ||
| 6471 | ✗ | tile+=3; | |
| 6472 | [[fallthrough]]; | ||
| 6473 | |||
| 6474 | case down: | ||
| 6475 | ✗ | tile+=3; | |
| 6476 | [[fallthrough]]; | ||
| 6477 | |||
| 6478 | case up: | ||
| 6479 | ✗ | break; | |
| 6480 | } | ||
| 6481 | ✗ | } | |
| 6482 | |||
| 6483 | 3057 | void enemy::tiledir_small(int32_t ndir, bool fourdir) | |
| 6484 | { | ||
| 6485 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3057 times.
|
3057 | if ( !do_animation ) return; |
| 6486 | 3057 | flip=0; | |
| 6487 | |||
| 6488 |
4/9✓ Branch 0 taken 801 times.
✓ Branch 1 taken 599 times.
✓ Branch 2 taken 1132 times.
✓ Branch 3 taken 525 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
3057 | switch(ndir) |
| 6489 | { | ||
| 6490 | case 8: | ||
| 6491 | case up: | ||
| 6492 | 801 | break; | |
| 6493 | |||
| 6494 | case 12: | ||
| 6495 | case down: | ||
| 6496 | 599 | tile+=2; | |
| 6497 | 599 | break; | |
| 6498 | |||
| 6499 | case 14: | ||
| 6500 | case left: | ||
| 6501 | 1132 | tile+=4; | |
| 6502 | 1132 | break; | |
| 6503 | |||
| 6504 | case 10: | ||
| 6505 | case right: | ||
| 6506 | 525 | tile+=6; | |
| 6507 | 525 | break; | |
| 6508 | |||
| 6509 | case 9: | ||
| 6510 | case r_up: | ||
| 6511 | ✗ | if(fourdir) | |
| 6512 | ✗ | break; | |
| 6513 | |||
| 6514 | ✗ | tile+=10; | |
| 6515 | ✗ | break; | |
| 6516 | |||
| 6517 | case 11: | ||
| 6518 | case r_down: | ||
| 6519 | ✗ | if(fourdir) | |
| 6520 | ✗ | tile+=2; | |
| 6521 | else | ||
| 6522 | ✗ | tile+=14; | |
| 6523 | |||
| 6524 | ✗ | break; | |
| 6525 | |||
| 6526 | case 13: | ||
| 6527 | case l_down: | ||
| 6528 | ✗ | if(fourdir) | |
| 6529 | ✗ | tile+=2; | |
| 6530 | else | ||
| 6531 | ✗ | tile+=12; | |
| 6532 | |||
| 6533 | ✗ | break; | |
| 6534 | |||
| 6535 | case 15: | ||
| 6536 | case l_up: | ||
| 6537 | ✗ | if(fourdir) | |
| 6538 | ✗ | break; | |
| 6539 | |||
| 6540 | ✗ | tile+=8; | |
| 6541 | ✗ | break; | |
| 6542 | |||
| 6543 | default: | ||
| 6544 | //dir=(zc_oldrand()*100)%8; | ||
| 6545 | //tiledir_small(dir); | ||
| 6546 | // flip=zc_oldrand()&3; | ||
| 6547 | // tile=(zc_oldrand()*100000)%NEWMAXTILES; | ||
| 6548 | ✗ | break; | |
| 6549 | } | ||
| 6550 | 3057 | } | |
| 6551 | |||
| 6552 | 171048 | void enemy::tiledir(int32_t ndir, bool fourdir) | |
| 6553 | { | ||
| 6554 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 171048 times.
|
171048 | if ( !do_animation ) return; |
| 6555 | 171048 | flip=0; | |
| 6556 | |||
| 6557 |
9/9✓ Branch 0 taken 34473 times.
✓ Branch 1 taken 32631 times.
✓ Branch 2 taken 41703 times.
✓ Branch 3 taken 45726 times.
✓ Branch 4 taken 2852 times.
✓ Branch 5 taken 5102 times.
✓ Branch 6 taken 3822 times.
✓ Branch 7 taken 4403 times.
✓ Branch 8 taken 336 times.
|
171048 | switch(ndir) |
| 6558 | { | ||
| 6559 | case 8: | ||
| 6560 | case up: | ||
| 6561 | 34473 | break; | |
| 6562 | |||
| 6563 | case 12: | ||
| 6564 | case down: | ||
| 6565 | 32631 | tile+=4; | |
| 6566 | 32631 | break; | |
| 6567 | |||
| 6568 | case 14: | ||
| 6569 | case left: | ||
| 6570 | 41703 | tile+=8; | |
| 6571 | 41703 | break; | |
| 6572 | |||
| 6573 | case 10: | ||
| 6574 | case right: | ||
| 6575 | 45726 | tile+=12; | |
| 6576 | 45726 | break; | |
| 6577 | |||
| 6578 | case 9: | ||
| 6579 | case r_up: | ||
| 6580 |
2/2✓ Branch 0 taken 306 times.
✓ Branch 1 taken 2546 times.
|
2852 | if(fourdir) |
| 6581 | 306 | break; | |
| 6582 | else | ||
| 6583 | 2546 | tile+=24; | |
| 6584 | |||
| 6585 | 2546 | break; | |
| 6586 | |||
| 6587 | case 11: | ||
| 6588 | case r_down: | ||
| 6589 |
2/2✓ Branch 0 taken 347 times.
✓ Branch 1 taken 4755 times.
|
5102 | if(fourdir) |
| 6590 | 347 | tile+=4; | |
| 6591 | else | ||
| 6592 | 4755 | tile+=32; | |
| 6593 | |||
| 6594 | 5102 | break; | |
| 6595 | |||
| 6596 | case 13: | ||
| 6597 | case l_down: | ||
| 6598 |
2/2✓ Branch 0 taken 276 times.
✓ Branch 1 taken 3546 times.
|
3822 | if(fourdir) |
| 6599 | 276 | tile+=4; | |
| 6600 | else | ||
| 6601 | 3546 | tile+=28; | |
| 6602 | |||
| 6603 | 3822 | break; | |
| 6604 | |||
| 6605 | case 15: | ||
| 6606 | case l_up: | ||
| 6607 |
2/2✓ Branch 0 taken 331 times.
✓ Branch 1 taken 4072 times.
|
4403 | if(fourdir) |
| 6608 | 331 | break; | |
| 6609 | else | ||
| 6610 | 4072 | tile+=20; | |
| 6611 | |||
| 6612 | 4072 | break; | |
| 6613 | |||
| 6614 | default: | ||
| 6615 | //dir=(zc_oldrand()*100)%8; | ||
| 6616 | //tiledir(dir); | ||
| 6617 | // flip=zc_oldrand()&3; | ||
| 6618 | // tile=(zc_oldrand()*100000)%NEWMAXTILES; | ||
| 6619 | 336 | break; | |
| 6620 | } | ||
| 6621 | 171048 | } | |
| 6622 | |||
| 6623 | ✗ | void enemy::tiledir_big(int32_t ndir, bool fourdir) | |
| 6624 | { | ||
| 6625 | ✗ | if ( !do_animation ) return; | |
| 6626 | ✗ | flip=0; | |
| 6627 | |||
| 6628 | ✗ | switch(ndir) | |
| 6629 | { | ||
| 6630 | case 8: | ||
| 6631 | case up: | ||
| 6632 | ✗ | break; | |
| 6633 | |||
| 6634 | case 12: | ||
| 6635 | case down: | ||
| 6636 | ✗ | tile+=8; | |
| 6637 | ✗ | break; | |
| 6638 | |||
| 6639 | case 14: | ||
| 6640 | case left: | ||
| 6641 | ✗ | tile+=40; | |
| 6642 | ✗ | break; | |
| 6643 | |||
| 6644 | case 10: | ||
| 6645 | case right: | ||
| 6646 | ✗ | tile+=48; | |
| 6647 | ✗ | break; | |
| 6648 | |||
| 6649 | case 9: | ||
| 6650 | case r_up: | ||
| 6651 | ✗ | if(fourdir) | |
| 6652 | ✗ | break; | |
| 6653 | |||
| 6654 | ✗ | tile+=88; | |
| 6655 | ✗ | break; | |
| 6656 | |||
| 6657 | case 11: | ||
| 6658 | case r_down: | ||
| 6659 | ✗ | if(fourdir) | |
| 6660 | ✗ | tile+=8; | |
| 6661 | else | ||
| 6662 | ✗ | tile+=128; | |
| 6663 | |||
| 6664 | ✗ | break; | |
| 6665 | |||
| 6666 | case 13: | ||
| 6667 | case l_down: | ||
| 6668 | ✗ | if(fourdir) | |
| 6669 | ✗ | tile+=8; | |
| 6670 | else | ||
| 6671 | ✗ | tile+=120; | |
| 6672 | |||
| 6673 | ✗ | break; | |
| 6674 | |||
| 6675 | case 15: | ||
| 6676 | case l_up: | ||
| 6677 | ✗ | if(fourdir) | |
| 6678 | ✗ | break; | |
| 6679 | |||
| 6680 | ✗ | tile+=80; | |
| 6681 | ✗ | break; | |
| 6682 | |||
| 6683 | default: | ||
| 6684 | //dir=(zc_oldrand()*100)%8; | ||
| 6685 | //tiledir_big(dir); | ||
| 6686 | // flip=zc_oldrand()&3; | ||
| 6687 | // tile=(zc_oldrand()*100000)%NEWMAXTILES; | ||
| 6688 | ✗ | break; | |
| 6689 | } | ||
| 6690 | ✗ | } | |
| 6691 | |||
| 6692 | 884056 | void enemy::update_enemy_frame() | |
| 6693 | { | ||
| 6694 |
3/4✓ Branch 0 taken 883914 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 883914 times.
|
884056 | if(fallclk||drownclk) return; |
| 6695 |
1/2✓ Branch 0 taken 883914 times.
✗ Branch 1 not taken.
|
883914 | if (!do_animation) |
| 6696 | ✗ | return; | |
| 6697 | |||
| 6698 |
3/4✓ Branch 0 taken 17128 times.
✓ Branch 1 taken 866786 times.
✓ Branch 2 taken 17128 times.
✗ Branch 3 not taken.
|
883914 | if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well. |
| 6699 | |||
| 6700 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
883914 | if(get_qr(qr_ANONE_NOANIM) |
| 6701 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 883914 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
883914 | && anim == aNONE && family != eeGUY) |
| 6702 | ✗ | return; | |
| 6703 |
2/2✓ Branch 0 taken 228 times.
✓ Branch 1 taken 883686 times.
|
883914 | int32_t newfrate = zc_max(frate,4); |
| 6704 | 883914 | int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3] | |
| 6705 | 883914 | int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1] | |
| 6706 |
2/2✓ Branch 0 taken 201460 times.
✓ Branch 1 taken 682454 times.
|
883914 | int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2; |
| 6707 | 883914 | tile = o_tile; | |
| 6708 | 883914 | int32_t basetile = o_tile; | |
| 6709 | 883914 | int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know. | |
| 6710 | 883914 | bool ignore_extend = false; | |
| 6711 |
27/40✓ Branch 0 taken 7708 times.
✓ Branch 1 taken 528 times.
✓ Branch 2 taken 5144 times.
✓ Branch 3 taken 148550 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 20622 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 68407 times.
✓ Branch 12 taken 1210 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 46429 times.
✓ Branch 16 taken 5103 times.
✓ Branch 17 taken 18584 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 8547 times.
✓ Branch 20 taken 15051 times.
✓ Branch 21 taken 2493 times.
✓ Branch 22 taken 131275 times.
✓ Branch 23 taken 34602 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 3057 times.
✓ Branch 26 taken 51462 times.
✓ Branch 27 taken 78169 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 75528 times.
✓ Branch 30 taken 57933 times.
✓ Branch 31 taken 34753 times.
✓ Branch 32 taken 16465 times.
✓ Branch 33 taken 4118 times.
✓ Branch 34 taken 1638 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 31353 times.
✓ Branch 37 taken 2468 times.
✓ Branch 38 taken 12717 times.
✗ Branch 39 not taken.
|
883914 | switch(anim) |
| 6712 | { | ||
| 6713 | |||
| 6714 | case aDONGO: | ||
| 6715 | { | ||
| 6716 | 1210 | int32_t fr = stunclk>0 ? 16 : 8; | |
| 6717 | |||
| 6718 |
6/6✓ Branch 0 taken 1192 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 1096 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 64 times.
|
1210 | if(!dying && clk2>0 && clk2<=64) |
| 6719 | { | ||
| 6720 | // bloated | ||
| 6721 |
1/5✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
64 | switch(dir) |
| 6722 | { | ||
| 6723 | case up: | ||
| 6724 | ✗ | tile+=9; | |
| 6725 | ✗ | flip=0; | |
| 6726 | ✗ | xofs=0; | |
| 6727 | ✗ | dummy_int[1]=0; //no additional tiles | |
| 6728 | ✗ | break; | |
| 6729 | |||
| 6730 | case down: | ||
| 6731 | 64 | tile+=7; | |
| 6732 | 64 | flip=0; | |
| 6733 | 64 | xofs=0; | |
| 6734 | 64 | dummy_int[1]=0; //no additional tiles | |
| 6735 | 64 | break; | |
| 6736 | |||
| 6737 | case left: | ||
| 6738 | ✗ | flip=1; | |
| 6739 | ✗ | tile+=4; | |
| 6740 | ✗ | xofs=16; | |
| 6741 | ✗ | dummy_int[1]=1; //second tile is next tile | |
| 6742 | ✗ | break; | |
| 6743 | |||
| 6744 | case right: | ||
| 6745 | ✗ | flip=0; | |
| 6746 | ✗ | tile+=5; | |
| 6747 | ✗ | xofs=16; | |
| 6748 | ✗ | dummy_int[1]=-1; //second tile is previous tile | |
| 6749 | ✗ | break; | |
| 6750 | } | ||
| 6751 | 64 | } | |
| 6752 |
3/4✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1128 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
|
1146 | else if(!dying || clk2>19) |
| 6753 | { | ||
| 6754 | // normal | ||
| 6755 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 219 times.
|
1128 | switch(dir) |
| 6756 | { | ||
| 6757 | case up: | ||
| 6758 | 87 | tile+=8; | |
| 6759 | 87 | flip=(clk&fr)?1:0; | |
| 6760 | 87 | xofs=0; | |
| 6761 | 87 | dummy_int[1]=0; //no additional tiles | |
| 6762 | 87 | break; | |
| 6763 | |||
| 6764 | case down: | ||
| 6765 | 564 | tile+=6; | |
| 6766 | 564 | flip=(clk&fr)?1:0; | |
| 6767 | 564 | xofs=0; | |
| 6768 | 564 | dummy_int[1]=0; //no additional tiles | |
| 6769 | 564 | break; | |
| 6770 | |||
| 6771 | case left: | ||
| 6772 | 258 | flip=1; | |
| 6773 | 258 | tile+=(clk&fr)?2:0; | |
| 6774 | 258 | xofs=16; | |
| 6775 | 258 | dummy_int[1]=1; //second tile is next tile | |
| 6776 | 258 | break; | |
| 6777 | |||
| 6778 | case right: | ||
| 6779 | 219 | flip=0; | |
| 6780 | 219 | tile+=(clk&fr)?3:1; | |
| 6781 | 219 | xofs=16; | |
| 6782 | 219 | dummy_int[1]=-1; //second tile is next tile | |
| 6783 | 219 | break; | |
| 6784 | } | ||
| 6785 | 1128 | } | |
| 6786 | } | ||
| 6787 | 1210 | break; | |
| 6788 | |||
| 6789 | case aNEWDONGO: | ||
| 6790 | { | ||
| 6791 | ✗ | int32_t fr4=0; | |
| 6792 | |||
| 6793 | ✗ | if(!dying && clk2>0 && clk2<=64) | |
| 6794 | { | ||
| 6795 | // bloated | ||
| 6796 | ✗ | if(clk2>=0) | |
| 6797 | { | ||
| 6798 | ✗ | fr4=3; | |
| 6799 | ✗ | } | |
| 6800 | |||
| 6801 | ✗ | if(clk2>=16) | |
| 6802 | { | ||
| 6803 | ✗ | fr4=2; | |
| 6804 | ✗ | } | |
| 6805 | |||
| 6806 | ✗ | if(clk2>=32) | |
| 6807 | { | ||
| 6808 | ✗ | fr4=1; | |
| 6809 | ✗ | } | |
| 6810 | |||
| 6811 | ✗ | if(clk2>=48) | |
| 6812 | { | ||
| 6813 | ✗ | fr4=0; | |
| 6814 | ✗ | } | |
| 6815 | |||
| 6816 | ✗ | switch(dir) | |
| 6817 | { | ||
| 6818 | case up: | ||
| 6819 | ✗ | xofs=0; | |
| 6820 | ✗ | tile+=8+fr4; | |
| 6821 | ✗ | dummy_int[1]=0; //no additional tiles | |
| 6822 | ✗ | break; | |
| 6823 | |||
| 6824 | case down: | ||
| 6825 | ✗ | xofs=0; | |
| 6826 | ✗ | tile+=12+fr4; | |
| 6827 | ✗ | dummy_int[1]=0; //no additional tiles | |
| 6828 | ✗ | break; | |
| 6829 | |||
| 6830 | case left: | ||
| 6831 | ✗ | tile+=29+(2*fr4); | |
| 6832 | ✗ | xofs=16; | |
| 6833 | ✗ | dummy_int[1]=-1; //second tile is previous tile | |
| 6834 | ✗ | break; | |
| 6835 | |||
| 6836 | case right: | ||
| 6837 | ✗ | tile+=49+(2*fr4); | |
| 6838 | ✗ | xofs=16; | |
| 6839 | ✗ | dummy_int[1]=-1; //second tile is previous tile | |
| 6840 | ✗ | break; | |
| 6841 | } | ||
| 6842 | ✗ | } | |
| 6843 | ✗ | else if(!dying || clk2>19) | |
| 6844 | { | ||
| 6845 | // normal | ||
| 6846 | ✗ | switch(dir) | |
| 6847 | { | ||
| 6848 | case up: | ||
| 6849 | ✗ | xofs=0; | |
| 6850 | ✗ | tile+=((clk&12)>>2); | |
| 6851 | ✗ | dummy_int[1]=0; //no additional tiles | |
| 6852 | ✗ | break; | |
| 6853 | |||
| 6854 | case down: | ||
| 6855 | ✗ | xofs=0; | |
| 6856 | ✗ | tile+=4+((clk&12)>>2); | |
| 6857 | ✗ | dummy_int[1]=0; //no additional tiles | |
| 6858 | ✗ | break; | |
| 6859 | |||
| 6860 | case left: | ||
| 6861 | ✗ | tile+=21+((clk&12)>>1); | |
| 6862 | ✗ | xofs=16; | |
| 6863 | ✗ | dummy_int[1]=-1; //second tile is previous tile | |
| 6864 | ✗ | break; | |
| 6865 | |||
| 6866 | case right: | ||
| 6867 | ✗ | flip=0; | |
| 6868 | ✗ | tile+=41+((clk&12)>>1); | |
| 6869 | ✗ | xofs=16; | |
| 6870 | ✗ | dummy_int[1]=-1; //second tile is previous tile | |
| 6871 | ✗ | break; | |
| 6872 | } | ||
| 6873 | ✗ | } | |
| 6874 | } | ||
| 6875 | ✗ | break; | |
| 6876 | |||
| 6877 | case aDONGOBS: | ||
| 6878 | { | ||
| 6879 | ✗ | int32_t fr4=0; | |
| 6880 | |||
| 6881 | ✗ | if(!dying && clk2>0 && clk2<=64) | |
| 6882 | { | ||
| 6883 | // bloated | ||
| 6884 | ✗ | if(clk2>=0) | |
| 6885 | { | ||
| 6886 | ✗ | fr4=3; | |
| 6887 | ✗ | } | |
| 6888 | |||
| 6889 | ✗ | if(clk2>=16) | |
| 6890 | { | ||
| 6891 | ✗ | fr4=2; | |
| 6892 | ✗ | } | |
| 6893 | |||
| 6894 | ✗ | if(clk2>=32) | |
| 6895 | { | ||
| 6896 | ✗ | fr4=1; | |
| 6897 | ✗ | } | |
| 6898 | |||
| 6899 | ✗ | if(clk2>=48) | |
| 6900 | { | ||
| 6901 | ✗ | fr4=0; | |
| 6902 | ✗ | } | |
| 6903 | |||
| 6904 | ✗ | switch(dir) | |
| 6905 | { | ||
| 6906 | case up: | ||
| 6907 | ✗ | tile+=28+fr4; | |
| 6908 | ✗ | yofs+=8; | |
| 6909 | ✗ | dummy_int[1]=-20; //second tile change | |
| 6910 | ✗ | dummy_int[2]=0; //new xofs change | |
| 6911 | ✗ | dummy_int[3]=-16; //new xofs change | |
| 6912 | ✗ | break; | |
| 6913 | |||
| 6914 | case down: | ||
| 6915 | ✗ | tile+=12+fr4; | |
| 6916 | ✗ | yofs-=8; | |
| 6917 | ✗ | dummy_int[1]=20; //second tile change | |
| 6918 | ✗ | dummy_int[2]=0; //new xofs change | |
| 6919 | ✗ | dummy_int[3]=16; //new xofs change | |
| 6920 | ✗ | break; | |
| 6921 | |||
| 6922 | case left: | ||
| 6923 | ✗ | tile+=49+(2*fr4); | |
| 6924 | ✗ | xofs+=8; | |
| 6925 | ✗ | dummy_int[1]=-1; //second tile change | |
| 6926 | ✗ | dummy_int[2]=-16; //new xofs change | |
| 6927 | ✗ | dummy_int[3]=0; //new xofs change | |
| 6928 | ✗ | break; | |
| 6929 | |||
| 6930 | case right: | ||
| 6931 | ✗ | tile+=69+(2*fr4); | |
| 6932 | ✗ | xofs+=8; | |
| 6933 | ✗ | dummy_int[1]=-1; //second tile change | |
| 6934 | ✗ | dummy_int[2]=-16; //new xofs change | |
| 6935 | ✗ | dummy_int[3]=0; //new xofs change | |
| 6936 | ✗ | break; | |
| 6937 | } | ||
| 6938 | ✗ | } | |
| 6939 | ✗ | else if(!dying || clk2>19) | |
| 6940 | { | ||
| 6941 | // normal | ||
| 6942 | ✗ | switch(dir) | |
| 6943 | { | ||
| 6944 | case up: | ||
| 6945 | ✗ | tile+=20+((clk&24)>>3); | |
| 6946 | ✗ | yofs+=8; | |
| 6947 | ✗ | dummy_int[1]=-20; //second tile change | |
| 6948 | ✗ | dummy_int[2]=0; //new xofs change | |
| 6949 | ✗ | dummy_int[3]=-16; //new xofs change | |
| 6950 | ✗ | break; | |
| 6951 | |||
| 6952 | case down: | ||
| 6953 | ✗ | tile+=4+((clk&24)>>3); | |
| 6954 | ✗ | yofs-=8; | |
| 6955 | ✗ | dummy_int[1]=20; //second tile change | |
| 6956 | ✗ | dummy_int[2]=0; //new xofs change | |
| 6957 | ✗ | dummy_int[3]=16; //new xofs change | |
| 6958 | ✗ | break; | |
| 6959 | |||
| 6960 | case left: | ||
| 6961 | ✗ | xofs=-8; | |
| 6962 | ✗ | tile+=40+((clk&24)>>2); | |
| 6963 | ✗ | dummy_int[1]=1; //second tile change | |
| 6964 | ✗ | dummy_int[2]=16; //new xofs change | |
| 6965 | ✗ | dummy_int[3]=0; //new xofs change | |
| 6966 | ✗ | break; | |
| 6967 | |||
| 6968 | case right: | ||
| 6969 | ✗ | tile+=60+((clk&24)>>2); | |
| 6970 | ✗ | xofs=-8; | |
| 6971 | ✗ | dummy_int[1]=1; //second tile change | |
| 6972 | ✗ | dummy_int[2]=16; //new xofs change | |
| 6973 | ✗ | dummy_int[3]=0; //new xofs change | |
| 6974 | ✗ | break; | |
| 6975 | } | ||
| 6976 | ✗ | } | |
| 6977 | } | ||
| 6978 | ✗ | break; | |
| 6979 | |||
| 6980 | case aWIZZ: | ||
| 6981 | { | ||
| 6982 | // if(d->misc1) | ||
| 6983 |
2/2✓ Branch 0 taken 35166 times.
✓ Branch 1 taken 11263 times.
|
46429 | if(dmisc1) |
| 6984 | { | ||
| 6985 |
2/2✓ Branch 0 taken 17752 times.
✓ Branch 1 taken 17414 times.
|
35166 | if(clk&8) |
| 6986 | { | ||
| 6987 | 17414 | ++tile; | |
| 6988 | 17414 | } | |
| 6989 | 35166 | } | |
| 6990 | else | ||
| 6991 | { | ||
| 6992 |
2/2✓ Branch 0 taken 5629 times.
✓ Branch 1 taken 5634 times.
|
11263 | if(frame&4) |
| 6993 | { | ||
| 6994 | 5634 | ++tile; | |
| 6995 | 5634 | } | |
| 6996 | } | ||
| 6997 | |||
| 6998 |
4/4✓ Branch 0 taken 7768 times.
✓ Branch 1 taken 15499 times.
✓ Branch 2 taken 14193 times.
✓ Branch 3 taken 8969 times.
|
46429 | switch(dir) |
| 6999 | { | ||
| 7000 | case 9: | ||
| 7001 | case 15: | ||
| 7002 | case up: | ||
| 7003 | 7768 | tile+=2; | |
| 7004 | 7768 | break; | |
| 7005 | |||
| 7006 | case down: | ||
| 7007 | 8969 | break; | |
| 7008 | |||
| 7009 | case 13: | ||
| 7010 | case left: | ||
| 7011 | 15499 | flip=1; | |
| 7012 | 15499 | break; | |
| 7013 | |||
| 7014 | default: | ||
| 7015 | 14193 | flip=0; | |
| 7016 | 14193 | break; | |
| 7017 | } | ||
| 7018 | } | ||
| 7019 | 46429 | break; | |
| 7020 | |||
| 7021 | case aNEWWIZZ: | ||
| 7022 | { | ||
| 7023 | 5103 | tiledir(dir,true); | |
| 7024 | |||
| 7025 | // if(d->misc1) //walking wizzrobe | ||
| 7026 |
2/2✓ Branch 0 taken 2310 times.
✓ Branch 1 taken 2793 times.
|
5103 | if(dmisc1) //walking wizzrobe |
| 7027 | { | ||
| 7028 |
2/2✓ Branch 0 taken 1145 times.
✓ Branch 1 taken 1165 times.
|
2310 | if(clk&8) |
| 7029 | { | ||
| 7030 | 1165 | tile+=2; | |
| 7031 | 1165 | } | |
| 7032 | |||
| 7033 |
2/2✓ Branch 0 taken 1141 times.
✓ Branch 1 taken 1169 times.
|
2310 | if(clk&4) |
| 7034 | { | ||
| 7035 | 1169 | tile+=1; | |
| 7036 | 1169 | } | |
| 7037 | |||
| 7038 |
2/4✓ Branch 0 taken 2310 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2310 times.
|
2310 | if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes |
| 7039 | { | ||
| 7040 |
2/2✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 245 times.
|
2310 | if(dummy_int[1]>0) |
| 7041 | { | ||
| 7042 | 245 | tile+=40; | |
| 7043 | 245 | } | |
| 7044 | 2310 | } | |
| 7045 | 2310 | } | |
| 7046 | else | ||
| 7047 | { | ||
| 7048 |
4/4✓ Branch 0 taken 2555 times.
✓ Branch 1 taken 238 times.
✓ Branch 2 taken 531 times.
✓ Branch 3 taken 2024 times.
|
2793 | if(dummy_bool[1]||dummy_bool[2]) |
| 7049 | { | ||
| 7050 | 769 | tile+=20; | |
| 7051 | |||
| 7052 |
2/2✓ Branch 0 taken 238 times.
✓ Branch 1 taken 531 times.
|
769 | if(dummy_bool[2]) |
| 7053 | { | ||
| 7054 | 531 | tile+=20; | |
| 7055 | 531 | } | |
| 7056 | 769 | } | |
| 7057 | |||
| 7058 | 2793 | tile+=((frame>>1)&3); | |
| 7059 | } | ||
| 7060 | } | ||
| 7061 | 5103 | break; | |
| 7062 | |||
| 7063 | case a3FRM: | ||
| 7064 | { | ||
| 7065 |
2/2✓ Branch 0 taken 4342 times.
✓ Branch 1 taken 14242 times.
|
18584 | basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4); |
| 7066 | } | ||
| 7067 | 18584 | break; | |
| 7068 | |||
| 7069 | case a3FRM4DIR: | ||
| 7070 | { | ||
| 7071 | ✗ | basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4); | |
| 7072 | } | ||
| 7073 | ✗ | break; | |
| 7074 | |||
| 7075 | case aVIRE: | ||
| 7076 | { | ||
| 7077 |
2/2✓ Branch 0 taken 6725 times.
✓ Branch 1 taken 1822 times.
|
8547 | if(dir==up) |
| 7078 | { | ||
| 7079 | 1822 | tile+=2; | |
| 7080 | 1822 | } | |
| 7081 | |||
| 7082 | 8547 | tile+=fx; | |
| 7083 | } | ||
| 7084 | 8547 | break; | |
| 7085 | |||
| 7086 | case aROPE: | ||
| 7087 | { | ||
| 7088 | 7708 | tile+=(1-fx); | |
| 7089 | 7708 | flip = dir==left ? 1:0; | |
| 7090 | } | ||
| 7091 | 7708 | break; | |
| 7092 | |||
| 7093 | case aZORA: | ||
| 7094 | { | ||
| 7095 | int32_t dl; | ||
| 7096 | |||
| 7097 |
2/2✓ Branch 0 taken 3550 times.
✓ Branch 1 taken 11501 times.
|
15051 | if(clk<36) |
| 7098 | { | ||
| 7099 | 3550 | dl=clk+5; | |
| 7100 | 3550 | goto waves2; | |
| 7101 | } | ||
| 7102 | |||
| 7103 |
2/2✓ Branch 0 taken 5802 times.
✓ Branch 1 taken 5699 times.
|
11501 | if(clk<36+66) |
| 7104 |
2/2✓ Branch 0 taken 3786 times.
✓ Branch 1 taken 2016 times.
|
5802 | tile=(dir==up)?o_tile+1:o_tile; |
| 7105 | else | ||
| 7106 | { | ||
| 7107 | 5699 | dl=clk-36-66; | |
| 7108 | waves2: | ||
| 7109 | 9249 | tile=((dl/11)&1)+s_tile; | |
| 7110 | 9249 | basetile = s_tile; | |
| 7111 | } | ||
| 7112 | } | ||
| 7113 | 15051 | break; | |
| 7114 | |||
| 7115 | case aNEWZORA: | ||
| 7116 | { | ||
| 7117 | 2493 | f4=(clk/16)%4; | |
| 7118 | |||
| 7119 | 2493 | tiledir(dir,true); | |
| 7120 | int32_t dl; | ||
| 7121 | |||
| 7122 |
4/4✓ Branch 0 taken 1823 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 827 times.
✓ Branch 3 taken 996 times.
|
2493 | if((clk>35)&&(clk<36+67)) //surfaced |
| 7123 | { | ||
| 7124 |
4/4✓ Branch 0 taken 833 times.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 723 times.
|
996 | if((clk>=(35+10))&&(clk<(38+56))) //mouth open |
| 7125 | { | ||
| 7126 | 723 | tile+=80; | |
| 7127 | 723 | } //mouth closed | |
| 7128 | else | ||
| 7129 | { | ||
| 7130 | 273 | tile+=40; | |
| 7131 | } | ||
| 7132 | |||
| 7133 | 996 | tile+=f4; | |
| 7134 | 996 | } | |
| 7135 | else | ||
| 7136 | { | ||
| 7137 |
2/2✓ Branch 0 taken 670 times.
✓ Branch 1 taken 827 times.
|
1497 | if(clk<36) |
| 7138 | { | ||
| 7139 | 670 | dl=clk+5; | |
| 7140 | 670 | } | |
| 7141 | else | ||
| 7142 | { | ||
| 7143 | 827 | dl=clk-36-66; | |
| 7144 | } | ||
| 7145 | |||
| 7146 | 1497 | tile+=((dl/5)&3); | |
| 7147 | } | ||
| 7148 | } | ||
| 7149 | 2493 | break; | |
| 7150 | |||
| 7151 | case a4FRM4EYE: | ||
| 7152 | case a2FRM4EYE: | ||
| 7153 | case a4FRM8EYE: | ||
| 7154 | case a4FRM8EYEB: //big version | ||
| 7155 | case a4FRM4EYEB: | ||
| 7156 | { | ||
| 7157 | ✗ | tilerows = 2; | |
| 7158 | ✗ | int fakex = x + 8*(zc_max(1,txsz)-1); | |
| 7159 | ✗ | int fakey = y + 8*(zc_max(1,tysz)-1); | |
| 7160 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 7161 | ✗ | double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex)); | |
| 7162 | ✗ | int32_t lookat=zc_oldrand()&15; | |
| 7163 | |||
| 7164 | ✗ | if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) | |
| 7165 | { | ||
| 7166 | ✗ | lookat=l_down; | |
| 7167 | ✗ | } | |
| 7168 | ✗ | else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8))) | |
| 7169 | { | ||
| 7170 | ✗ | lookat=down; | |
| 7171 | ✗ | } | |
| 7172 | ✗ | else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8))) | |
| 7173 | { | ||
| 7174 | ✗ | lookat=r_down; | |
| 7175 | ✗ | } | |
| 7176 | ✗ | else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8))) | |
| 7177 | { | ||
| 7178 | ✗ | lookat=right; | |
| 7179 | ✗ | } | |
| 7180 | ✗ | else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8))) | |
| 7181 | { | ||
| 7182 | ✗ | lookat=r_up; | |
| 7183 | ✗ | } | |
| 7184 | ✗ | else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8))) | |
| 7185 | { | ||
| 7186 | ✗ | lookat=up; | |
| 7187 | ✗ | } | |
| 7188 | ✗ | else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8))) | |
| 7189 | { | ||
| 7190 | ✗ | lookat=l_up; | |
| 7191 | ✗ | } | |
| 7192 | else | ||
| 7193 | { | ||
| 7194 | ✗ | lookat=left; | |
| 7195 | } | ||
| 7196 | |||
| 7197 | ✗ | int32_t dir2 = dir; | |
| 7198 | ✗ | dir = lookat; | |
| 7199 | ✗ | if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4); | |
| 7200 | else | ||
| 7201 | { | ||
| 7202 | ✗ | tiledir_big(dir,(anim == a4FRM4EYEB)); | |
| 7203 | ✗ | tile+=2*f4; | |
| 7204 | ✗ | ignore_extend = true; | |
| 7205 | } | ||
| 7206 | ✗ | dir = dir2; | |
| 7207 | } | ||
| 7208 | ✗ | break; | |
| 7209 | |||
| 7210 | case aFLIP: | ||
| 7211 | { | ||
| 7212 | 131275 | flip = f2&1; | |
| 7213 | } | ||
| 7214 | 131275 | break; | |
| 7215 | |||
| 7216 | case a2FRM: | ||
| 7217 | { | ||
| 7218 | 34602 | tile += (1-f2); | |
| 7219 | } | ||
| 7220 | 34602 | break; | |
| 7221 | |||
| 7222 | case a2FRMB: | ||
| 7223 | { | ||
| 7224 | ✗ | tile+= 2*(1-f2); | |
| 7225 | ✗ | ignore_extend = true; | |
| 7226 | } | ||
| 7227 | ✗ | break; | |
| 7228 | |||
| 7229 | case a2FRM4DIR: | ||
| 7230 | { | ||
| 7231 | 3057 | basetile = n_frame_n_dir(2, 4, f2&1); | |
| 7232 | } | ||
| 7233 | 3057 | break; | |
| 7234 | |||
| 7235 | case a4FRM4DIRF: | ||
| 7236 | { | ||
| 7237 | 51462 | basetile = n_frame_n_dir(4,4,f4); | |
| 7238 | |||
| 7239 |
2/2✓ Branch 0 taken 34911 times.
✓ Branch 1 taken 16551 times.
|
51462 | if(clk2>0) //stopped to fire |
| 7240 | { | ||
| 7241 | 16551 | tile+=20; | |
| 7242 | |||
| 7243 |
2/2✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 7308 times.
|
16551 | if(clk2<17) //firing |
| 7244 | { | ||
| 7245 | 7308 | tile+=20; | |
| 7246 | 7308 | } | |
| 7247 | 16551 | } | |
| 7248 | } | ||
| 7249 | 51462 | break; | |
| 7250 | |||
| 7251 | case a4FRM4DIR: | ||
| 7252 | { | ||
| 7253 | 78169 | basetile = n_frame_n_dir(4,4,f4); | |
| 7254 | } | ||
| 7255 | 78169 | break; | |
| 7256 | |||
| 7257 | case a4FRM8DIRF: | ||
| 7258 | { | ||
| 7259 | ✗ | tilerows = 2; | |
| 7260 | ✗ | basetile = n_frame_n_dir(4,8,f4); | |
| 7261 | |||
| 7262 | ✗ | if(clk2>0) //stopped to fire | |
| 7263 | { | ||
| 7264 | ✗ | tile+=40; | |
| 7265 | |||
| 7266 | ✗ | if(clk2<17) //firing | |
| 7267 | { | ||
| 7268 | ✗ | tile+=40; | |
| 7269 | ✗ | } | |
| 7270 | ✗ | } | |
| 7271 | } | ||
| 7272 | ✗ | break; | |
| 7273 | |||
| 7274 | case a4FRM8DIRB: | ||
| 7275 | case a4FRM8DIRFB: | ||
| 7276 | { | ||
| 7277 | ✗ | tilerows = 2; | |
| 7278 | ✗ | tiledir_big(dir,false); | |
| 7279 | ✗ | tile+=2*f4; | |
| 7280 | ✗ | if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire | |
| 7281 | { | ||
| 7282 | ✗ | tile+=80; | |
| 7283 | |||
| 7284 | ✗ | if(clk2<17) //firing | |
| 7285 | { | ||
| 7286 | ✗ | tile+=80; | |
| 7287 | ✗ | } | |
| 7288 | ✗ | } | |
| 7289 | ✗ | ignore_extend = true; | |
| 7290 | } | ||
| 7291 | ✗ | break; | |
| 7292 | |||
| 7293 | case a4FRM4DIRB: | ||
| 7294 | case a4FRM4DIRFB: | ||
| 7295 | { | ||
| 7296 | ✗ | tilerows = 2; | |
| 7297 | ✗ | tiledir_big(dir,true); | |
| 7298 | ✗ | tile+=2*f4; | |
| 7299 | ✗ | if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire | |
| 7300 | { | ||
| 7301 | ✗ | tile+=40; | |
| 7302 | |||
| 7303 | ✗ | if(clk2<17) //firing | |
| 7304 | { | ||
| 7305 | ✗ | tile+=40; | |
| 7306 | ✗ | } | |
| 7307 | ✗ | } | |
| 7308 | ✗ | ignore_extend = true; | |
| 7309 | } | ||
| 7310 | ✗ | break; | |
| 7311 | |||
| 7312 | case aOCTO: | ||
| 7313 | { | ||
| 7314 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 16013 times.
✓ Branch 2 taken 17806 times.
✓ Branch 3 taken 22111 times.
✓ Branch 4 taken 19598 times.
|
75528 | switch(dir) |
| 7315 | { | ||
| 7316 | case up: | ||
| 7317 | 16013 | flip = 2; | |
| 7318 | 16013 | break; | |
| 7319 | |||
| 7320 | case down: | ||
| 7321 | 17806 | flip = 0; | |
| 7322 | 17806 | break; | |
| 7323 | |||
| 7324 | case left: | ||
| 7325 | 22111 | flip = 0; | |
| 7326 | 22111 | tile += 2; | |
| 7327 | 22111 | break; | |
| 7328 | |||
| 7329 | case right: | ||
| 7330 | 19598 | flip = 1; | |
| 7331 | 19598 | tile += 2; | |
| 7332 | 19598 | break; | |
| 7333 | } | ||
| 7334 | |||
| 7335 | 75528 | tile+=f2; | |
| 7336 | } | ||
| 7337 | 75528 | break; | |
| 7338 | |||
| 7339 | case aWALK: | ||
| 7340 | { | ||
| 7341 |
5/5✓ Branch 0 taken 9 times.
✓ Branch 1 taken 12450 times.
✓ Branch 2 taken 13592 times.
✓ Branch 3 taken 17367 times.
✓ Branch 4 taken 14515 times.
|
57933 | switch(dir) |
| 7342 | { | ||
| 7343 | case up: | ||
| 7344 | 12450 | tile+=3; | |
| 7345 | 12450 | flip = f2; | |
| 7346 | 12450 | break; | |
| 7347 | |||
| 7348 | case down: | ||
| 7349 | 13592 | tile+=2; | |
| 7350 | 13592 | flip = f2; | |
| 7351 | 13592 | break; | |
| 7352 | |||
| 7353 | case left: | ||
| 7354 | 17367 | flip=1; | |
| 7355 | 17367 | tile += f2; | |
| 7356 | 17367 | break; | |
| 7357 | |||
| 7358 | case right: | ||
| 7359 | 14515 | flip=0; | |
| 7360 | 14515 | tile += f2; | |
| 7361 | 14515 | break; | |
| 7362 | } | ||
| 7363 | } | ||
| 7364 | 57933 | break; | |
| 7365 | |||
| 7366 | case aDWALK: | ||
| 7367 | { | ||
| 7368 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 34753 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
34753 | if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true)) |
| 7369 | { | ||
| 7370 | ✗ | tile=s_tile; | |
| 7371 | ✗ | basetile = s_tile; | |
| 7372 | ✗ | } | |
| 7373 | |||
| 7374 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 7077 times.
✓ Branch 2 taken 6808 times.
✓ Branch 3 taken 9768 times.
✓ Branch 4 taken 11100 times.
|
34753 | switch(dir) |
| 7375 | { | ||
| 7376 | case up: | ||
| 7377 | 7077 | tile+=2; | |
| 7378 | 7077 | flip=f2; | |
| 7379 | 7077 | break; | |
| 7380 | |||
| 7381 | case down: | ||
| 7382 | 6808 | flip=0; | |
| 7383 | 6808 | tile+=(1-f2); | |
| 7384 | 6808 | break; | |
| 7385 | |||
| 7386 | case left: | ||
| 7387 | 9768 | flip=1; | |
| 7388 | 9768 | tile+=(3+f2); | |
| 7389 | 9768 | break; | |
| 7390 | |||
| 7391 | case right: | ||
| 7392 | 11100 | flip=0; | |
| 7393 | 11100 | tile+=(3+f2); | |
| 7394 | 11100 | break; | |
| 7395 | } | ||
| 7396 | } | ||
| 7397 | 34753 | break; | |
| 7398 | |||
| 7399 | case aTEK: | ||
| 7400 | { | ||
| 7401 |
2/2✓ Branch 0 taken 10902 times.
✓ Branch 1 taken 5563 times.
|
16465 | if(misc==0) |
| 7402 | { | ||
| 7403 | 5563 | tile += f2; | |
| 7404 | 5563 | } | |
| 7405 |
2/2✓ Branch 0 taken 5778 times.
✓ Branch 1 taken 5124 times.
|
10902 | else if(misc!=1) |
| 7406 | { | ||
| 7407 | 5124 | ++tile; | |
| 7408 | 5124 | } | |
| 7409 | } | ||
| 7410 | 16465 | break; | |
| 7411 | |||
| 7412 | case aNEWTEK: | ||
| 7413 | { | ||
| 7414 |
2/2✓ Branch 0 taken 1356 times.
✓ Branch 1 taken 2762 times.
|
4118 | if(step<0) //up |
| 7415 | { | ||
| 7416 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 491 times.
✓ Branch 2 taken 865 times.
|
1356 | switch(clk3) |
| 7417 | { | ||
| 7418 | case left: | ||
| 7419 | 491 | flip=0; | |
| 7420 | 491 | tile+=20; | |
| 7421 | 491 | break; | |
| 7422 | |||
| 7423 | case right: | ||
| 7424 | 865 | flip=0; | |
| 7425 | 865 | tile+=24; | |
| 7426 | 865 | break; | |
| 7427 | } | ||
| 7428 | 1356 | } | |
| 7429 |
2/2✓ Branch 0 taken 185 times.
✓ Branch 1 taken 2577 times.
|
2762 | else if(step==0) |
| 7430 | { | ||
| 7431 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
✓ Branch 2 taken 28 times.
|
185 | switch(clk3) |
| 7432 | { | ||
| 7433 | case left: | ||
| 7434 | 157 | flip=0; | |
| 7435 | 157 | tile+=8; | |
| 7436 | 157 | break; | |
| 7437 | |||
| 7438 | case right: | ||
| 7439 | 28 | flip=0; | |
| 7440 | 28 | tile+=12; | |
| 7441 | 28 | break; | |
| 7442 | } | ||
| 7443 | 185 | } //down | |
| 7444 | else | ||
| 7445 | { | ||
| 7446 |
3/3✓ Branch 0 taken 380 times.
✓ Branch 1 taken 790 times.
✓ Branch 2 taken 1407 times.
|
2577 | switch(clk3) |
| 7447 | { | ||
| 7448 | case left: | ||
| 7449 | 790 | flip=0; | |
| 7450 | 790 | tile+=28; | |
| 7451 | 790 | break; | |
| 7452 | |||
| 7453 | case right: | ||
| 7454 | 1407 | flip=0; | |
| 7455 | 1407 | tile+=32; | |
| 7456 | 1407 | break; | |
| 7457 | } | ||
| 7458 | } | ||
| 7459 | |||
| 7460 |
2/2✓ Branch 0 taken 3185 times.
✓ Branch 1 taken 933 times.
|
4118 | if(misc==0) |
| 7461 | { | ||
| 7462 | 933 | tile+=f4; | |
| 7463 | 933 | } | |
| 7464 |
2/2✓ Branch 0 taken 1476 times.
✓ Branch 1 taken 1709 times.
|
3185 | else if(misc!=1) |
| 7465 | { | ||
| 7466 | 1709 | tile+=2; | |
| 7467 | 1709 | } | |
| 7468 | } | ||
| 7469 | 4118 | break; | |
| 7470 | |||
| 7471 | case aARMOS: | ||
| 7472 | { | ||
| 7473 |
2/2✓ Branch 0 taken 183 times.
✓ Branch 1 taken 345 times.
|
528 | if(!fading) |
| 7474 | { | ||
| 7475 | 345 | tile += fx; | |
| 7476 | |||
| 7477 |
2/2✓ Branch 0 taken 195 times.
✓ Branch 1 taken 150 times.
|
345 | if(dir==up) |
| 7478 | 150 | tile += 2; | |
| 7479 | 345 | } | |
| 7480 | } | ||
| 7481 | 528 | break; | |
| 7482 | |||
| 7483 | case aARMOS4: | ||
| 7484 | { | ||
| 7485 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 1234 times.
✓ Branch 3 taken 1629 times.
✓ Branch 4 taken 1484 times.
|
5144 | switch(dir) |
| 7486 | { | ||
| 7487 | case up: | ||
| 7488 | 797 | flip=0; | |
| 7489 | 797 | break; | |
| 7490 | |||
| 7491 | case down: | ||
| 7492 | 1234 | flip=0; | |
| 7493 | 1234 | tile+=4; | |
| 7494 | 1234 | break; | |
| 7495 | |||
| 7496 | case left: | ||
| 7497 | 1629 | flip=0; | |
| 7498 | 1629 | tile+=8; | |
| 7499 | 1629 | break; | |
| 7500 | |||
| 7501 | case right: | ||
| 7502 | 1484 | flip=0; | |
| 7503 | 1484 | tile+=12; | |
| 7504 | 1484 | break; | |
| 7505 | } | ||
| 7506 | |||
| 7507 |
2/2✓ Branch 0 taken 464 times.
✓ Branch 1 taken 4680 times.
|
5144 | if(!fading) |
| 7508 | { | ||
| 7509 | 4680 | tile+=f4; | |
| 7510 | 4680 | } | |
| 7511 | } | ||
| 7512 | 5144 | break; | |
| 7513 | |||
| 7514 | case aGHINI: | ||
| 7515 | { | ||
| 7516 |
3/4✓ Branch 0 taken 191 times.
✓ Branch 1 taken 507 times.
✓ Branch 2 taken 940 times.
✗ Branch 3 not taken.
|
1638 | switch(dir) |
| 7517 | { | ||
| 7518 | case 8: | ||
| 7519 | case 9: | ||
| 7520 | case up: | ||
| 7521 | 191 | ++tile; | |
| 7522 | 191 | flip=0; | |
| 7523 | 191 | break; | |
| 7524 | |||
| 7525 | case 15: | ||
| 7526 | ✗ | ++tile; | |
| 7527 | ✗ | flip=1; | |
| 7528 | ✗ | break; | |
| 7529 | |||
| 7530 | case 10: | ||
| 7531 | case 11: | ||
| 7532 | case right: | ||
| 7533 | 507 | flip=1; | |
| 7534 | 507 | break; | |
| 7535 | |||
| 7536 | default: | ||
| 7537 | 940 | flip=0; | |
| 7538 | 940 | break; | |
| 7539 | } | ||
| 7540 | } | ||
| 7541 | 1638 | break; | |
| 7542 | |||
| 7543 | case a2FRMPOS: | ||
| 7544 | { | ||
| 7545 | 148550 | tile+=posframe; | |
| 7546 | } | ||
| 7547 | 148550 | break; | |
| 7548 | |||
| 7549 | case a4FRMPOS4DIR: | ||
| 7550 | { | ||
| 7551 | ✗ | basetile = n_frame_n_dir(4,4,0); | |
| 7552 | // tile+=f2; | ||
| 7553 | ✗ | tile+=posframe; | |
| 7554 | } | ||
| 7555 | ✗ | break; | |
| 7556 | |||
| 7557 | case a4FRMPOS4DIRF: | ||
| 7558 | { | ||
| 7559 | ✗ | basetile = n_frame_n_dir(4,4,0); | |
| 7560 | |||
| 7561 | ✗ | if(clk2>0) //stopped to fire | |
| 7562 | { | ||
| 7563 | ✗ | tile+=20; | |
| 7564 | |||
| 7565 | ✗ | if(clk2<17) //firing | |
| 7566 | { | ||
| 7567 | ✗ | tile+=20; | |
| 7568 | ✗ | } | |
| 7569 | ✗ | } | |
| 7570 | |||
| 7571 | // tile+=f2; | ||
| 7572 | ✗ | tile+=posframe; | |
| 7573 | } | ||
| 7574 | ✗ | break; | |
| 7575 | |||
| 7576 | case a4FRMPOS8DIR: | ||
| 7577 | { | ||
| 7578 | 31353 | tilerows = 2; | |
| 7579 | 31353 | int32_t n = tile; | |
| 7580 | 31353 | basetile = n_frame_n_dir(4,8,0); | |
| 7581 | // tile+=f2; | ||
| 7582 | 31353 | tile+=posframe; | |
| 7583 | } | ||
| 7584 | 31353 | break; | |
| 7585 | |||
| 7586 | case a4FRMPOS8DIRF: | ||
| 7587 | { | ||
| 7588 | ✗ | tilerows = 2; | |
| 7589 | ✗ | basetile = n_frame_n_dir(4,8,0); | |
| 7590 | |||
| 7591 | ✗ | if(clk2>0) //stopped to fire | |
| 7592 | { | ||
| 7593 | ✗ | tile+=40; | |
| 7594 | |||
| 7595 | ✗ | if(clk2<17) //firing | |
| 7596 | { | ||
| 7597 | ✗ | tile+=40; | |
| 7598 | ✗ | } | |
| 7599 | ✗ | } | |
| 7600 | |||
| 7601 | ✗ | tile+=posframe; | |
| 7602 | } | ||
| 7603 | ✗ | break; | |
| 7604 | |||
| 7605 | case aNEWLEV: | ||
| 7606 | { | ||
| 7607 | 2468 | tiledir(dir,true); | |
| 7608 | |||
| 7609 |
4/5✓ Branch 0 taken 1212 times.
✓ Branch 1 taken 349 times.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 730 times.
|
2468 | switch(misc) |
| 7610 | { | ||
| 7611 | case -1: | ||
| 7612 | case 0: | ||
| 7613 | 1212 | return; | |
| 7614 | |||
| 7615 | case 1: | ||
| 7616 | |||
| 7617 | // case 5: cs = d->misc2; break; | ||
| 7618 | case 5: | ||
| 7619 | 349 | cs = dmisc2; | |
| 7620 | 349 | break; | |
| 7621 | |||
| 7622 | case 2: | ||
| 7623 | case 4: | ||
| 7624 | 177 | tile += 20; | |
| 7625 | 177 | break; | |
| 7626 | |||
| 7627 | case 3: | ||
| 7628 | 730 | tile += 40; | |
| 7629 | 730 | break; | |
| 7630 | } | ||
| 7631 | |||
| 7632 | 1256 | tile+=f4; | |
| 7633 | } | ||
| 7634 | 1256 | break; | |
| 7635 | |||
| 7636 | case aLEV: | ||
| 7637 | { | ||
| 7638 | 12717 | f4 = ((clk/5)&1); | |
| 7639 | |||
| 7640 |
4/5✓ Branch 0 taken 6004 times.
✓ Branch 1 taken 1157 times.
✓ Branch 2 taken 651 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4905 times.
|
12717 | switch(misc) |
| 7641 | { | ||
| 7642 | case -1: | ||
| 7643 | case 0: | ||
| 7644 | 6004 | return; | |
| 7645 | |||
| 7646 | case 1: | ||
| 7647 | |||
| 7648 | // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break; | ||
| 7649 | case 5: | ||
| 7650 | 1157 | tile += (f2) ? 1 : 0; | |
| 7651 | 1157 | cs = dmisc2; | |
| 7652 | 1157 | break; | |
| 7653 | |||
| 7654 | case 2: | ||
| 7655 | case 4: | ||
| 7656 | 651 | tile += 2; | |
| 7657 | 651 | break; | |
| 7658 | |||
| 7659 | case 3: | ||
| 7660 | 4905 | tile += (f4) ? 4 : 3; | |
| 7661 | 4905 | break; | |
| 7662 | } | ||
| 7663 | } | ||
| 7664 | 6713 | break; | |
| 7665 | |||
| 7666 | case aWALLM: | ||
| 7667 | { | ||
| 7668 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20622 times.
|
20622 | if(!dummy_bool[1]) |
| 7669 | { | ||
| 7670 | 20622 | tile += f2; | |
| 7671 | 20622 | } | |
| 7672 | } | ||
| 7673 | 20622 | break; | |
| 7674 | |||
| 7675 | case aNEWWALLM: | ||
| 7676 | { | ||
| 7677 | ✗ | int32_t tempdir=0; | |
| 7678 | |||
| 7679 | ✗ | switch(misc) | |
| 7680 | { | ||
| 7681 | case 1: | ||
| 7682 | case 2: | ||
| 7683 | ✗ | tempdir=clk3; | |
| 7684 | ✗ | break; | |
| 7685 | |||
| 7686 | case 3: | ||
| 7687 | case 4: | ||
| 7688 | case 5: | ||
| 7689 | ✗ | tempdir=dir; | |
| 7690 | ✗ | break; | |
| 7691 | |||
| 7692 | case 6: | ||
| 7693 | case 7: | ||
| 7694 | ✗ | tempdir=clk3^1; | |
| 7695 | ✗ | break; | |
| 7696 | } | ||
| 7697 | |||
| 7698 | ✗ | tiledir(tempdir,true); | |
| 7699 | |||
| 7700 | ✗ | if(!dummy_bool[1]) | |
| 7701 | { | ||
| 7702 | ✗ | tile+=f4; | |
| 7703 | ✗ | } | |
| 7704 | } | ||
| 7705 | ✗ | break; | |
| 7706 | |||
| 7707 | case a4FRMNODIR: | ||
| 7708 | { | ||
| 7709 | ✗ | tile+=f4; | |
| 7710 | } | ||
| 7711 | ✗ | break; | |
| 7712 | |||
| 7713 | } // switch(d->anim) | ||
| 7714 | |||
| 7715 | // flashing | ||
| 7716 | // if(d->flags2 & guy_flashing) | ||
| 7717 |
2/2✓ Branch 0 taken 842316 times.
✓ Branch 1 taken 34382 times.
|
876698 | if(flags2 & guy_flashing) |
| 7718 | { | ||
| 7719 | 34382 | cs = (frame&3) + 6; | |
| 7720 | 34382 | } | |
| 7721 | |||
| 7722 |
2/2✓ Branch 0 taken 876428 times.
✓ Branch 1 taken 270 times.
|
876698 | if(flags2&guy_transparent) |
| 7723 | { | ||
| 7724 | 270 | drawstyle=1; | |
| 7725 | 270 | } | |
| 7726 | |||
| 7727 | 876698 | int32_t change = tile-basetile; | |
| 7728 | |||
| 7729 |
3/6✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 870155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6543 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
876698 | if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION))) |
| 7730 | { | ||
| 7731 |
2/2✓ Branch 0 taken 2476 times.
✓ Branch 1 taken 4067 times.
|
6543 | if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW) |
| 7732 | { | ||
| 7733 | 2476 | tile=basetile+txsz*change; | |
| 7734 | 2476 | } | |
| 7735 | else | ||
| 7736 | { | ||
| 7737 | 4067 | tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW)); | |
| 7738 | } | ||
| 7739 | 6543 | } | |
| 7740 | else | ||
| 7741 | { | ||
| 7742 | 870155 | tile=basetile+change; | |
| 7743 | } | ||
| 7744 | 884056 | } | |
| 7745 | |||
| 7746 | 1310 | int32_t wpnsfx(int32_t wpn) | |
| 7747 | { | ||
| 7748 |
4/6✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 532 times.
✓ Branch 4 taken 238 times.
✓ Branch 5 taken 486 times.
|
1310 | switch(wpn) |
| 7749 | { | ||
| 7750 | case ewFireTrail: | ||
| 7751 | case ewFlame: | ||
| 7752 | case ewFlame2Trail: | ||
| 7753 | case ewFlame2: | ||
| 7754 | 54 | return WAV_FIRE; | |
| 7755 | |||
| 7756 | case ewWind: | ||
| 7757 | case ewMagic: | ||
| 7758 | ✗ | return WAV_WAND; | |
| 7759 | |||
| 7760 | case ewIce: | ||
| 7761 | ✗ | return WAV_ZN1ICE; | |
| 7762 | |||
| 7763 | case ewRock: | ||
| 7764 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 464 times.
|
486 | if(get_qr(qr_MORESOUNDS)) return WAV_ZN1ROCK; |
| 7765 | 464 | break; | |
| 7766 | |||
| 7767 | case ewFireball2: | ||
| 7768 | case ewFireball: | ||
| 7769 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 523 times.
|
532 | if(get_qr(qr_MORESOUNDS)) return WAV_ZN1FIREBALL; |
| 7770 | 523 | } | |
| 7771 | |||
| 7772 | 1225 | return -1; | |
| 7773 | 1310 | } | |
| 7774 | |||
| 7775 | 1691731 | int32_t enemy::run_script(int32_t mode) | |
| 7776 | { | ||
| 7777 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1691731 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1691731 | if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK; |
| 7778 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1691731 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1691731 | if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS]) |
| 7779 | 1691731 | return RUNSCRIPT_OK; | |
| 7780 | ✗ | auto scrty = *get_scrtype(); | |
| 7781 | ✗ | auto uid = getUID(); | |
| 7782 | ✗ | if(!FFCore.doscript(scrty,uid)) | |
| 7783 | ✗ | return RUNSCRIPT_OK; | |
| 7784 | ✗ | int32_t ret = RUNSCRIPT_OK; | |
| 7785 | ✗ | bool& waitdraw = FFCore.waitdraw(scrty, uid); | |
| 7786 | ✗ | switch(mode) | |
| 7787 | { | ||
| 7788 | case MODE_NORMAL: | ||
| 7789 | ✗ | return ZScriptVersion::RunScript(ScriptType::NPC, script, uid); | |
| 7790 | case MODE_WAITDRAW: | ||
| 7791 | ✗ | if(waitdraw) | |
| 7792 | { | ||
| 7793 | ✗ | ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid); | |
| 7794 | ✗ | waitdraw = false; | |
| 7795 | ✗ | } | |
| 7796 | ✗ | break; | |
| 7797 | } | ||
| 7798 | ✗ | return ret; | |
| 7799 | 1691731 | } | |
| 7800 | ✗ | ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const | |
| 7801 | { | ||
| 7802 | ✗ | return al_map_rgba(255,0,0,opacity); | |
| 7803 | } | ||
| 7804 | /********************************/ | ||
| 7805 | /********* Guy Class **********/ | ||
| 7806 | /********************************/ | ||
| 7807 | |||
| 7808 | // good guys, fires, fairy, and other non-enemies | ||
| 7809 | // based on enemy class b/c guys in dungeons act sort of like enemies | ||
| 7810 | // also easier to manage all the guys this way | ||
| 7811 | 174 | guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk) | |
| 7812 | 174 | { | |
| 7813 | 174 | mainguy=mg; | |
| 7814 | 174 | canfreeze=false; | |
| 7815 | 174 | dir=down; | |
| 7816 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 174 times.
✗ Branch 3 not taken.
|
174 | yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); |
| 7817 | 174 | hxofs=2; | |
| 7818 | 174 | hzsz=8; | |
| 7819 | 174 | hit_width=12; | |
| 7820 | 174 | hit_height=17; | |
| 7821 | |||
| 7822 |
9/12✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 118 times.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 40 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 14 times.
|
174 | if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA)) |
| 7823 | { | ||
| 7824 | 160 | superman = 1; | |
| 7825 | 160 | hxofs=1000; | |
| 7826 | 160 | } | |
| 7827 | 174 | } | |
| 7828 | |||
| 7829 | 61972 | bool guy::animate(int32_t index) | |
| 7830 | { | ||
| 7831 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61972 times.
|
61972 | if(switch_hooked) return enemy::animate(index); |
| 7832 |
6/6✓ Branch 0 taken 22630 times.
✓ Branch 1 taken 39342 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 22336 times.
✓ Branch 4 taken 227 times.
✓ Branch 5 taken 67 times.
|
61972 | if(mainguy && clk==0 && misc==0) |
| 7833 | { | ||
| 7834 | 67 | setupscreen(); | |
| 7835 | 67 | misc = 1; | |
| 7836 | 67 | } | |
| 7837 | |||
| 7838 |
4/4✓ Branch 0 taken 22630 times.
✓ Branch 1 taken 39342 times.
✓ Branch 2 taken 22598 times.
✓ Branch 3 taken 32 times.
|
61972 | if(mainguy && fadeclk==0) |
| 7839 | 32 | return true; | |
| 7840 | |||
| 7841 | 61940 | hp=256; // good guys never die... | |
| 7842 | |||
| 7843 |
4/4✓ Branch 0 taken 99 times.
✓ Branch 1 taken 61841 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 3 times.
|
61940 | if(hclk && !clk2) |
| 7844 | { | ||
| 7845 | // but if they get hit... | ||
| 7846 | 3 | ++clk2; // only do this once | |
| 7847 | |||
| 7848 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if(!get_qr(qr_NOGUYFIRES)) |
| 7849 | { | ||
| 7850 | 3 | addenemy(BSZ?64:72,68,eSHOOTFBALL,0); | |
| 7851 | 3 | addenemy(BSZ?176:168,68,eSHOOTFBALL,0); | |
| 7852 | 3 | } | |
| 7853 | 3 | } | |
| 7854 | |||
| 7855 | 61940 | return enemy::animate(index); | |
| 7856 | 61972 | } | |
| 7857 | |||
| 7858 | 62405 | void guy::draw(BITMAP *dest) | |
| 7859 | { | ||
| 7860 | 62405 | update_enemy_frame(); | |
| 7861 | |||
| 7862 |
6/6✓ Branch 0 taken 23028 times.
✓ Branch 1 taken 39377 times.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 20916 times.
✓ Branch 4 taken 1056 times.
✓ Branch 5 taken 1056 times.
|
62405 | if(!mainguy || fadeclk<0 || fadeclk&1) |
| 7863 | 61349 | enemy::draw(dest); | |
| 7864 | 62405 | } | |
| 7865 | |||
| 7866 | /*******************************/ | ||
| 7867 | /********* Enemies *********/ | ||
| 7868 | /*******************************/ | ||
| 7869 | |||
| 7870 | 8 | eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 7871 | 8 | { | |
| 7872 | 8 | clk4=0; | |
| 7873 | 8 | shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0; | |
| 7874 | // Spawn type | ||
| 7875 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if(flags & guy_fadeflicker) |
| 7876 | { | ||
| 7877 | ✗ | clk=0; | |
| 7878 | ✗ | superman = 1; | |
| 7879 | ✗ | fading=fade_flicker; | |
| 7880 | ✗ | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; | |
| 7881 | ✗ | dir=down; | |
| 7882 | |||
| 7883 | ✗ | if(!canmove(down,(zfix)8,spw_none,false)) | |
| 7884 | ✗ | clk3=int32_t(13.0/step); | |
| 7885 | ✗ | } | |
| 7886 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | else if(flags & guy_fadeinstant) |
| 7887 | { | ||
| 7888 | ✗ | clk=0; | |
| 7889 | ✗ | } | |
| 7890 | 8 | SIZEflags = d->SIZEflags; | |
| 7891 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
8 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 7892 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 7893 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 7894 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
8 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 7895 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 7896 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 7897 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 7898 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 7899 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 7900 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 7901 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 7902 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 7903 | { | ||
| 7904 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 7905 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 7906 | ✗ | } | |
| 7907 | |||
| 7908 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs; |
| 7909 | 8 | } | |
| 7910 | |||
| 7911 | 397 | bool eFire::animate(int32_t index) | |
| 7912 | { | ||
| 7913 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 397 times.
|
397 | if(switch_hooked) return enemy::animate(index); |
| 7914 |
2/4✓ Branch 0 taken 397 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 397 times.
|
397 | if(fallclk||drownclk) return enemy::animate(index); |
| 7915 |
1/2✓ Branch 0 taken 397 times.
✗ Branch 1 not taken.
|
397 | if(fading) |
| 7916 | { | ||
| 7917 | ✗ | if(++clk4 > 60) | |
| 7918 | { | ||
| 7919 | ✗ | clk4=0; | |
| 7920 | ✗ | superman=0; | |
| 7921 | ✗ | fading=0; | |
| 7922 | |||
| 7923 | ✗ | if(flags2&cmbflag_armos && z==0 && fakez==0) | |
| 7924 | ✗ | removearmos(x,y,ffcactivated); | |
| 7925 | |||
| 7926 | ✗ | clk2=0; | |
| 7927 | |||
| 7928 | ✗ | if(!canmove(down,(zfix)8,spw_none,false)) | |
| 7929 | { | ||
| 7930 | ✗ | dir=0; | |
| 7931 | ✗ | y = y.getInt() & 0xF0; | |
| 7932 | ✗ | } | |
| 7933 | |||
| 7934 | ✗ | return Dead(index); | |
| 7935 | } | ||
| 7936 | ✗ | else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0) | |
| 7937 | ✗ | removearmos(x,y,ffcactivated); | |
| 7938 | ✗ | } | |
| 7939 | |||
| 7940 | 397 | return enemy::animate(index); | |
| 7941 | 397 | } | |
| 7942 | |||
| 7943 | 3802 | void eFire::draw(BITMAP *dest) | |
| 7944 | { | ||
| 7945 | 3802 | update_enemy_frame(); | |
| 7946 | 3802 | enemy::draw(dest); | |
| 7947 | 3802 | } | |
| 7948 | |||
| 7949 | 4 | int32_t eFire::takehit(weapon *w, weapon* realweap) | |
| 7950 | { | ||
| 7951 | 4 | int32_t wpnId = w->id; | |
| 7952 | 4 | int32_t wpnDir = w->dir; | |
| 7953 | |||
| 7954 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if(wpnId==wHammer && shield && (flags & guy_bkshield) |
| 7955 | ✗ | && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up)) | |
| 7956 | ✗ | || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right)))) | |
| 7957 | { | ||
| 7958 | ✗ | shield = false; | |
| 7959 | ✗ | flags &= ~(inv_left|inv_right|inv_back|inv_front); | |
| 7960 | |||
| 7961 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 7962 | ✗ | o_tile=s_tile; | |
| 7963 | ✗ | } | |
| 7964 | |||
| 7965 | 4 | int32_t ret = enemy::takehit(w,realweap); | |
| 7966 | 4 | return ret; | |
| 7967 | } | ||
| 7968 | |||
| 7969 | ✗ | void eFire::break_shield() | |
| 7970 | { | ||
| 7971 | ✗ | if(!shield) | |
| 7972 | ✗ | return; | |
| 7973 | |||
| 7974 | ✗ | flags&=~(inv_front | inv_back | inv_left | inv_right); | |
| 7975 | ✗ | shield=false; | |
| 7976 | |||
| 7977 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 7978 | ✗ | o_tile=s_tile; | |
| 7979 | ✗ | } | |
| 7980 | |||
| 7981 | 10 | eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 7982 | 10 | { | |
| 7983 | //zprint2("npct other::other\n"); | ||
| 7984 | 10 | clk4=0; | |
| 7985 | 10 | shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0; | |
| 7986 | |||
| 7987 | // Spawn type | ||
| 7988 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
10 | if(flags & guy_fadeflicker) |
| 7989 | { | ||
| 7990 | ✗ | clk=0; | |
| 7991 | ✗ | superman = 1; | |
| 7992 | ✗ | fading=fade_flicker; | |
| 7993 | ✗ | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; | |
| 7994 | ✗ | dir=down; | |
| 7995 | |||
| 7996 | ✗ | if(!canmove(down,(zfix)8,spw_none,false)) | |
| 7997 | ✗ | clk3=int32_t(13.0/step); | |
| 7998 | ✗ | } | |
| 7999 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
|
10 | else if(flags & guy_fadeinstant) |
| 8000 | { | ||
| 8001 | 2 | clk=0; | |
| 8002 | 2 | } | |
| 8003 | 10 | SIZEflags = d->SIZEflags; | |
| 8004 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
10 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 8005 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 8006 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 8007 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
10 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 8008 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
10 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 8009 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
10 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 8010 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
10 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 8011 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 8012 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 8013 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 8014 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
10 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 8015 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
10 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 8016 | { | ||
| 8017 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 8018 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 8019 | ✗ | } | |
| 8020 | |||
| 8021 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
10 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 8022 | 10 | } | |
| 8023 | |||
| 8024 | 1652 | bool eOther::animate(int32_t index) | |
| 8025 | { | ||
| 8026 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1652 times.
|
1652 | if(switch_hooked) return enemy::animate(index); |
| 8027 |
2/4✓ Branch 0 taken 1652 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1652 times.
|
1652 | if(fallclk||drownclk) return enemy::animate(index); |
| 8028 | //zprint2("npct other::animate\n"); | ||
| 8029 |
2/2✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 15 times.
|
1652 | if(fading) |
| 8030 | { | ||
| 8031 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
15 | if(++clk4 > 60) |
| 8032 | { | ||
| 8033 | ✗ | clk4=0; | |
| 8034 | ✗ | superman=0; | |
| 8035 | ✗ | fading=0; | |
| 8036 | |||
| 8037 | ✗ | if(flags2&cmbflag_armos && z==0 && fakez==0) | |
| 8038 | ✗ | removearmos(x,y,ffcactivated); | |
| 8039 | |||
| 8040 | ✗ | clk2=0; | |
| 8041 | |||
| 8042 | ✗ | if(!canmove(down,(zfix)8,spw_none,false)) | |
| 8043 | { | ||
| 8044 | ✗ | dir=0; | |
| 8045 | ✗ | y = y.getInt() & 0xF0; | |
| 8046 | ✗ | } | |
| 8047 | |||
| 8048 | ✗ | return Dead(index); | |
| 8049 | } | ||
| 8050 |
1/8✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
15 | else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0) |
| 8051 | ✗ | removearmos(x,y,ffcactivated); | |
| 8052 | 15 | } | |
| 8053 | |||
| 8054 | 1652 | return enemy::animate(index); | |
| 8055 | 1652 | } | |
| 8056 | |||
| 8057 | 1944 | void eOther::draw(BITMAP *dest) | |
| 8058 | { | ||
| 8059 | 1944 | update_enemy_frame(); | |
| 8060 | 1944 | enemy::draw(dest); | |
| 8061 | 1944 | } | |
| 8062 | |||
| 8063 | 5 | int32_t eOther::takehit(weapon *w, weapon* realweap) | |
| 8064 | { | ||
| 8065 | 5 | int32_t wpnId = w->id; | |
| 8066 | 5 | int32_t wpnDir = w->dir; | |
| 8067 | |||
| 8068 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5 | if(wpnId==wHammer && shield && (flags & guy_bkshield) |
| 8069 | ✗ | && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up)) | |
| 8070 | ✗ | || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right)))) | |
| 8071 | { | ||
| 8072 | ✗ | shield = false; | |
| 8073 | ✗ | flags &= ~(inv_left|inv_right|inv_back|inv_front); | |
| 8074 | |||
| 8075 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 8076 | ✗ | o_tile=s_tile; | |
| 8077 | ✗ | } | |
| 8078 | |||
| 8079 | 5 | int32_t ret = enemy::takehit(w,realweap); | |
| 8080 | 5 | return ret; | |
| 8081 | } | ||
| 8082 | |||
| 8083 | ✗ | void eOther::break_shield() | |
| 8084 | { | ||
| 8085 | ✗ | if(!shield) | |
| 8086 | ✗ | return; | |
| 8087 | |||
| 8088 | ✗ | flags&=~(inv_front | inv_back | inv_left | inv_right); | |
| 8089 | ✗ | shield=false; | |
| 8090 | |||
| 8091 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 8092 | ✗ | o_tile=s_tile; | |
| 8093 | ✗ | } | |
| 8094 | |||
| 8095 | |||
| 8096 | ✗ | eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 8097 | ✗ | { | |
| 8098 | ✗ | clk4=0; | |
| 8099 | ✗ | shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0; | |
| 8100 | |||
| 8101 | // Spawn type | ||
| 8102 | ✗ | if(flags & guy_fadeflicker) | |
| 8103 | { | ||
| 8104 | ✗ | clk=0; | |
| 8105 | ✗ | superman = 1; | |
| 8106 | ✗ | fading=fade_flicker; | |
| 8107 | ✗ | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; | |
| 8108 | ✗ | dir=down; | |
| 8109 | |||
| 8110 | ✗ | if(!canmove(down,(zfix)8,spw_none,false)) | |
| 8111 | ✗ | clk3=int32_t(13.0/step); | |
| 8112 | ✗ | } | |
| 8113 | ✗ | else if(flags & guy_fadeinstant) | |
| 8114 | { | ||
| 8115 | ✗ | clk=0; | |
| 8116 | ✗ | } | |
| 8117 | ✗ | SIZEflags = d->SIZEflags; | |
| 8118 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. | |
| 8119 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 8120 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 8121 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } | |
| 8122 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; | |
| 8123 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; | |
| 8124 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; | |
| 8125 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; | |
| 8126 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; | |
| 8127 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 8128 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; | |
| 8129 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) | |
| 8130 | { | ||
| 8131 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 8132 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 8133 | ✗ | } | |
| 8134 | |||
| 8135 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; | |
| 8136 | ✗ | } | |
| 8137 | |||
| 8138 | ✗ | bool eScript::animate(int32_t index) | |
| 8139 | { | ||
| 8140 | ✗ | if(switch_hooked) return enemy::animate(index); | |
| 8141 | ✗ | if(fallclk||drownclk) return enemy::animate(index); | |
| 8142 | ✗ | if(fading) | |
| 8143 | { | ||
| 8144 | ✗ | if(++clk4 > 60) | |
| 8145 | { | ||
| 8146 | ✗ | clk4=0; | |
| 8147 | ✗ | superman=0; | |
| 8148 | ✗ | fading=0; | |
| 8149 | |||
| 8150 | ✗ | if(flags2&cmbflag_armos && z==0 && fakez==0) | |
| 8151 | ✗ | removearmos(x,y,ffcactivated); | |
| 8152 | |||
| 8153 | ✗ | clk2=0; | |
| 8154 | |||
| 8155 | ✗ | if(!canmove(down,(zfix)8,spw_none,false)) | |
| 8156 | { | ||
| 8157 | ✗ | dir=0; | |
| 8158 | ✗ | y = y.getInt() & 0xF0; | |
| 8159 | ✗ | } | |
| 8160 | |||
| 8161 | ✗ | return Dead(index); | |
| 8162 | } | ||
| 8163 | ✗ | else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0) | |
| 8164 | ✗ | removearmos(x,y,ffcactivated); | |
| 8165 | ✗ | } | |
| 8166 | |||
| 8167 | ✗ | return enemy::animate(index); | |
| 8168 | ✗ | } | |
| 8169 | |||
| 8170 | ✗ | void eScript::draw(BITMAP *dest) | |
| 8171 | { | ||
| 8172 | ✗ | update_enemy_frame(); | |
| 8173 | ✗ | enemy::draw(dest); | |
| 8174 | ✗ | } | |
| 8175 | |||
| 8176 | ✗ | int32_t eScript::takehit(weapon *w, weapon* realweap) | |
| 8177 | { | ||
| 8178 | ✗ | int32_t wpnId = w->id; | |
| 8179 | ✗ | int32_t wpnDir = w->dir; | |
| 8180 | |||
| 8181 | ✗ | if(wpnId==wHammer && shield && (flags & guy_bkshield) | |
| 8182 | ✗ | && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up)) | |
| 8183 | ✗ | || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right)))) | |
| 8184 | { | ||
| 8185 | ✗ | shield = false; | |
| 8186 | ✗ | flags &= ~(inv_left|inv_right|inv_back|inv_front); | |
| 8187 | |||
| 8188 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 8189 | ✗ | o_tile=s_tile; | |
| 8190 | ✗ | } | |
| 8191 | |||
| 8192 | ✗ | int32_t ret = enemy::takehit(w,realweap); | |
| 8193 | ✗ | return ret; | |
| 8194 | } | ||
| 8195 | |||
| 8196 | ✗ | void eScript::break_shield() | |
| 8197 | { | ||
| 8198 | ✗ | if(!shield) | |
| 8199 | ✗ | return; | |
| 8200 | |||
| 8201 | ✗ | flags&=~(inv_front | inv_back | inv_left | inv_right); | |
| 8202 | ✗ | shield=false; | |
| 8203 | |||
| 8204 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 8205 | ✗ | o_tile=s_tile; | |
| 8206 | ✗ | } | |
| 8207 | |||
| 8208 | |||
| 8209 | ✗ | eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 8210 | ✗ | { | |
| 8211 | ✗ | clk4=0; | |
| 8212 | ✗ | hyofs = -32768; //No hitbox initially. | |
| 8213 | ✗ | shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0; | |
| 8214 | |||
| 8215 | // Spawn type | ||
| 8216 | ✗ | if(flags & guy_fadeflicker) | |
| 8217 | { | ||
| 8218 | ✗ | clk=0; | |
| 8219 | ✗ | superman = 1; | |
| 8220 | ✗ | fading=fade_flicker; | |
| 8221 | ✗ | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; | |
| 8222 | ✗ | dir=down; | |
| 8223 | |||
| 8224 | ✗ | if(!canmove(down,(zfix)8,spw_none,false)) | |
| 8225 | ✗ | clk3=int32_t(13.0/step); | |
| 8226 | ✗ | } | |
| 8227 | ✗ | else if(flags & guy_fadeinstant) | |
| 8228 | { | ||
| 8229 | ✗ | clk=0; | |
| 8230 | ✗ | } | |
| 8231 | ✗ | SIZEflags = d->SIZEflags; | |
| 8232 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. | |
| 8233 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 8234 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 8235 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } | |
| 8236 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; | |
| 8237 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; | |
| 8238 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; | |
| 8239 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; | |
| 8240 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; | |
| 8241 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 8242 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; | |
| 8243 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) | |
| 8244 | { | ||
| 8245 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 8246 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 8247 | ✗ | } | |
| 8248 | |||
| 8249 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; | |
| 8250 | ✗ | } | |
| 8251 | |||
| 8252 | ✗ | bool eFriendly::animate(int32_t index) | |
| 8253 | { | ||
| 8254 | ✗ | if(switch_hooked) return enemy::animate(index); | |
| 8255 | ✗ | if(fallclk||drownclk) return enemy::animate(index); | |
| 8256 | ✗ | if(fading) | |
| 8257 | { | ||
| 8258 | ✗ | if(++clk4 > 60) | |
| 8259 | { | ||
| 8260 | ✗ | clk4=0; | |
| 8261 | ✗ | superman=0; | |
| 8262 | ✗ | fading=0; | |
| 8263 | |||
| 8264 | ✗ | if(flags2&cmbflag_armos && z==0 && fakez==0) | |
| 8265 | ✗ | removearmos(x,y,ffcactivated); | |
| 8266 | |||
| 8267 | ✗ | clk2=0; | |
| 8268 | |||
| 8269 | ✗ | if(!canmove(down,(zfix)8,spw_none,false)) | |
| 8270 | { | ||
| 8271 | ✗ | dir=0; | |
| 8272 | ✗ | y = y.getInt() & 0xF0; | |
| 8273 | ✗ | } | |
| 8274 | |||
| 8275 | ✗ | return Dead(index); | |
| 8276 | } | ||
| 8277 | ✗ | else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0) | |
| 8278 | ✗ | removearmos(x,y,ffcactivated); | |
| 8279 | ✗ | } | |
| 8280 | |||
| 8281 | ✗ | return enemy::animate(index); | |
| 8282 | ✗ | } | |
| 8283 | |||
| 8284 | ✗ | void eFriendly::draw(BITMAP *dest) | |
| 8285 | { | ||
| 8286 | ✗ | update_enemy_frame(); | |
| 8287 | ✗ | enemy::draw(dest); | |
| 8288 | ✗ | } | |
| 8289 | |||
| 8290 | ✗ | int32_t eFriendly::takehit(weapon *w, weapon* realweap) | |
| 8291 | { | ||
| 8292 | ✗ | int32_t wpnId = w->id; | |
| 8293 | ✗ | int32_t wpnDir = w->dir; | |
| 8294 | |||
| 8295 | ✗ | if(wpnId==wHammer && shield && (flags & guy_bkshield) | |
| 8296 | ✗ | && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up)) | |
| 8297 | ✗ | || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right)))) | |
| 8298 | { | ||
| 8299 | ✗ | shield = false; | |
| 8300 | ✗ | flags &= ~(inv_left|inv_right|inv_back|inv_front); | |
| 8301 | |||
| 8302 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 8303 | ✗ | o_tile=s_tile; | |
| 8304 | ✗ | } | |
| 8305 | |||
| 8306 | ✗ | int32_t ret = enemy::takehit(w,realweap); | |
| 8307 | ✗ | return ret; | |
| 8308 | } | ||
| 8309 | |||
| 8310 | ✗ | void eFriendly::break_shield() | |
| 8311 | { | ||
| 8312 | ✗ | if(!shield) | |
| 8313 | ✗ | return; | |
| 8314 | |||
| 8315 | ✗ | flags&=~(inv_front | inv_back | inv_left | inv_right); | |
| 8316 | ✗ | shield=false; | |
| 8317 | |||
| 8318 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 8319 | ✗ | o_tile=s_tile; | |
| 8320 | ✗ | } | |
| 8321 | |||
| 8322 | |||
| 8323 | 10100 | void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive) | |
| 8324 | { | ||
| 8325 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10100 times.
|
10100 | if (ffcactive) |
| 8326 | { | ||
| 8327 | ✗ | removearmosffc(ffcactive-1); | |
| 8328 | ✗ | return; | |
| 8329 | } | ||
| 8330 |
2/2✓ Branch 0 taken 10077 times.
✓ Branch 1 taken 23 times.
|
10100 | if(did_armos) |
| 8331 | { | ||
| 8332 | 10077 | return; | |
| 8333 | } | ||
| 8334 | |||
| 8335 | 23 | did_armos=true; | |
| 8336 | 23 | ax&=0xF0; | |
| 8337 | 23 | ay&=0xF0; | |
| 8338 | 23 | int32_t cd = (ax>>4)+ay; | |
| 8339 | 23 | int32_t f = MAPFLAG(ax,ay); | |
| 8340 | 23 | int32_t f2 = MAPCOMBOFLAG(ax,ay); | |
| 8341 | |||
| 8342 |
2/2✓ Branch 0 taken 17 times.
✓ Branch 1 taken 6 times.
|
23 | if(combobuf[tmpscr->data[cd]].type!=cARMOS) |
| 8343 | { | ||
| 8344 | 17 | return; | |
| 8345 | } | ||
| 8346 | |||
| 8347 | 6 | tmpscr->data[cd] = tmpscr->undercombo; | |
| 8348 | 6 | tmpscr->cset[cd] = tmpscr->undercset; | |
| 8349 | 6 | tmpscr->sflag[cd] = 0; | |
| 8350 | |||
| 8351 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
|
6 | if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET) |
| 8352 | { | ||
| 8353 | ✗ | tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS]; | |
| 8354 | ✗ | tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS]; | |
| 8355 | ✗ | tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS]; | |
| 8356 | ✗ | sfx(tmpscr->secretsfx); | |
| 8357 | ✗ | } | |
| 8358 | |||
| 8359 |
3/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
|
6 | if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM) |
| 8360 | { | ||
| 8361 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1 | if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)) |
| 8362 | { | ||
| 8363 | 1 | additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0)); | |
| 8364 | 1 | sfx(tmpscr->secretsfx); | |
| 8365 | 1 | } | |
| 8366 | 1 | } | |
| 8367 | |||
| 8368 | 6 | putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]); | |
| 8369 | 10100 | } | |
| 8370 | |||
| 8371 | ✗ | void enemy::removearmosffc(int32_t pos) | |
| 8372 | { | ||
| 8373 | ✗ | if(did_armos) | |
| 8374 | { | ||
| 8375 | ✗ | return; | |
| 8376 | } | ||
| 8377 | |||
| 8378 | ✗ | did_armos=true; | |
| 8379 | ✗ | ffcdata& ffc = tmpscr->ffcs[pos]; | |
| 8380 | ✗ | newcombo const& cmb = combobuf[ffc.data]; | |
| 8381 | ✗ | int32_t f2 = cmb.flag; | |
| 8382 | |||
| 8383 | ✗ | if(cmb.type!=cARMOS) | |
| 8384 | { | ||
| 8385 | ✗ | return; | |
| 8386 | } | ||
| 8387 | |||
| 8388 | ✗ | zc_ffc_set(ffc, tmpscr->undercombo); | |
| 8389 | ✗ | ffc.cset = tmpscr->undercset; | |
| 8390 | |||
| 8391 | ✗ | if(f2 == mfARMOS_SECRET) | |
| 8392 | { | ||
| 8393 | ✗ | zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]); | |
| 8394 | ✗ | ffc.cset = tmpscr->secretcset[sSTAIRS]; | |
| 8395 | ✗ | sfx(tmpscr->secretsfx); | |
| 8396 | ✗ | } | |
| 8397 | |||
| 8398 | ✗ | if(f2 == mfARMOS_ITEM) | |
| 8399 | { | ||
| 8400 | ✗ | if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)) | |
| 8401 | { | ||
| 8402 | ✗ | additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0)); | |
| 8403 | ✗ | sfx(tmpscr->secretsfx); | |
| 8404 | ✗ | } | |
| 8405 | ✗ | } | |
| 8406 | |||
| 8407 | ✗ | putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset); | |
| 8408 | ✗ | } | |
| 8409 | |||
| 8410 | |||
| 8411 | 1 | eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 8412 | 1 | { | |
| 8413 | 1 | fading=fade_flicker; | |
| 8414 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; |
| 8415 | 1 | dir=12; | |
| 8416 | 1 | movestatus=1; | |
| 8417 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | step=0; |
| 8418 | 1 | clk=0; | |
| 8419 | 1 | clk4=0; | |
| 8420 | 1 | SIZEflags = d->SIZEflags; | |
| 8421 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 8422 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 8423 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 8424 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 8425 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 8426 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 8427 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 8428 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 8429 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 8430 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 8431 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 8432 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 8433 | { | ||
| 8434 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 8435 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 8436 | ✗ | } | |
| 8437 | |||
| 8438 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 8439 | 1 | } | |
| 8440 | |||
| 8441 | 169 | bool eGhini::animate(int32_t index) | |
| 8442 | { | ||
| 8443 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 169 times.
|
169 | if(switch_hooked) return enemy::animate(index); |
| 8444 |
2/4✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 169 times.
|
169 | if(fallclk||drownclk) return enemy::animate(index); |
| 8445 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 169 times.
|
169 | if(dying) |
| 8446 | ✗ | return Dead(index); | |
| 8447 | |||
| 8448 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 169 times.
|
169 | if(dmisc1) |
| 8449 | { | ||
| 8450 |
2/2✓ Branch 0 taken 108 times.
✓ Branch 1 taken 61 times.
|
169 | if(misc) |
| 8451 | { | ||
| 8452 |
2/2✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8 times.
|
108 | if(clk4>160) |
| 8453 | 8 | misc=2; | |
| 8454 | |||
| 8455 |
2/2✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8 times.
|
108 | floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10); |
| 8456 | 108 | removearmos(x,y,ffcactivated); | |
| 8457 | 108 | } | |
| 8458 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 1 times.
|
61 | else if(clk4>=60) |
| 8459 | { | ||
| 8460 | 1 | misc=1; | |
| 8461 | 1 | clk3=32; | |
| 8462 | 1 | fading=0; | |
| 8463 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (ffcactivated > 0) |
| 8464 | { | ||
| 8465 | ✗ | guygridffc[ffcactivated-1] = 0; | |
| 8466 | ✗ | removearmosffc(ffcactivated-1); | |
| 8467 | ✗ | } | |
| 8468 | else | ||
| 8469 | { | ||
| 8470 | 1 | guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0; | |
| 8471 | 1 | removearmos(x,y); | |
| 8472 | } | ||
| 8473 | 1 | } | |
| 8474 | 169 | } | |
| 8475 | |||
| 8476 | 169 | clk4++; | |
| 8477 | |||
| 8478 | 169 | return enemy::animate(index); | |
| 8479 | 169 | } | |
| 8480 | |||
| 8481 | 338 | void eGhini::draw(BITMAP *dest) | |
| 8482 | { | ||
| 8483 | 338 | update_enemy_frame(); | |
| 8484 | 338 | enemy::draw(dest); | |
| 8485 | 338 | } | |
| 8486 | |||
| 8487 | ✗ | void eGhini::kickbucket() | |
| 8488 | { | ||
| 8489 | ✗ | hp=-1000; // don't call death_sfx() | |
| 8490 | ✗ | } | |
| 8491 | |||
| 8492 |
2/4✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
|
210 | eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) |
| 8493 | 105 | { | |
| 8494 |
1/2✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
|
105 | old_y=y; |
| 8495 | 105 | dir=down; | |
| 8496 | 105 | misc=1; | |
| 8497 | 105 | clk=-15; | |
| 8498 | |||
| 8499 |
2/2✓ Branch 0 taken 94 times.
✓ Branch 1 taken 11 times.
|
105 | if(!BSZ) |
| 8500 |
1/2✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
|
94 | clk*=zc_oldrand()%3+1; |
| 8501 | |||
| 8502 | // avoid divide by 0 errors | ||
| 8503 |
1/2✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
|
105 | if(dmisc1 == 0) |
| 8504 | ✗ | dmisc1 = 24; | |
| 8505 | |||
| 8506 |
1/2✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
|
105 | if(dmisc2 == 0) |
| 8507 | ✗ | dmisc2 = 3; | |
| 8508 | |||
| 8509 | //nets+760; | ||
| 8510 | 105 | SIZEflags = d->SIZEflags; | |
| 8511 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
105 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 8512 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 8513 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 8514 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
105 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 8515 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
105 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 8516 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
105 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 8517 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
105 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 8518 |
1/2✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
|
105 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 8519 |
1/2✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
|
105 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 8520 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 8521 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
105 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 8522 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
|
105 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 8523 | { | ||
| 8524 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 8525 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 8526 | ✗ | } | |
| 8527 | |||
| 8528 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
105 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 8529 | 105 | } | |
| 8530 | |||
| 8531 | 19270 | bool eTektite::animate(int32_t index) | |
| 8532 | { | ||
| 8533 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 19270 times.
|
19270 | if(switch_hooked) return enemy::animate(index); |
| 8534 |
4/4✓ Branch 0 taken 19106 times.
✓ Branch 1 taken 164 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 19122 times.
|
19270 | if(fallclk||drownclk) return enemy::animate(index); |
| 8535 |
2/2✓ Branch 0 taken 450 times.
✓ Branch 1 taken 18672 times.
|
19122 | if(dying) |
| 8536 | 450 | return Dead(index); | |
| 8537 | |||
| 8538 |
2/2✓ Branch 0 taken 18209 times.
✓ Branch 1 taken 463 times.
|
18672 | if(clk==0) |
| 8539 | { | ||
| 8540 | 463 | removearmos(x,y,ffcactivated); | |
| 8541 | 463 | } | |
| 8542 | |||
| 8543 |
2/2✓ Branch 0 taken 17811 times.
✓ Branch 1 taken 861 times.
|
18672 | if(get_qr(qr_ENEMIESZAXIS)) |
| 8544 | { | ||
| 8545 | 861 | y=floor_y; | |
| 8546 | 861 | } | |
| 8547 | |||
| 8548 |
8/10✓ Branch 0 taken 15746 times.
✓ Branch 1 taken 2926 times.
✓ Branch 2 taken 15746 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15746 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✓ Branch 7 taken 15596 times.
✓ Branch 8 taken 121 times.
✓ Branch 9 taken 271 times.
|
18672 | if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0)) |
| 8549 | { | ||
| 8550 |
4/4✓ Branch 0 taken 258 times.
✓ Branch 1 taken 6085 times.
✓ Branch 2 taken 3568 times.
✓ Branch 3 taken 5956 times.
|
15867 | switch(misc) |
| 8551 | { | ||
| 8552 | case 0: // normal | ||
| 8553 |
2/2✓ Branch 0 taken 5965 times.
✓ Branch 1 taken 120 times.
|
6085 | if(!(zc_oldrand()%dmisc1)) |
| 8554 | { | ||
| 8555 | 120 | misc=1; | |
| 8556 | 120 | clk2=32; | |
| 8557 | 120 | } | |
| 8558 | |||
| 8559 | 6085 | break; | |
| 8560 | |||
| 8561 | case 1: // waiting to pounce | ||
| 8562 |
2/2✓ Branch 0 taken 3318 times.
✓ Branch 1 taken 250 times.
|
3568 | if(--clk2<=0) |
| 8563 | { | ||
| 8564 | 250 | int32_t r=zc_oldrand(); | |
| 8565 | 250 | misc=2; | |
| 8566 | 250 | step=0-(zslongToFix(dstep*100)); // initial speed | |
| 8567 | 250 | clk3=(r&1)+2; // left or right | |
| 8568 | 250 | clk2start=clk2=(r&31)+10; // flight time | |
| 8569 | |||
| 8570 |
2/2✓ Branch 0 taken 227 times.
✓ Branch 1 taken 23 times.
|
250 | if(y<32) clk2+=2; // make them come down from top of screen |
| 8571 | |||
| 8572 |
2/2✓ Branch 0 taken 190 times.
✓ Branch 1 taken 60 times.
|
250 | if(y>112) clk2-=2; // make them go back up |
| 8573 | |||
| 8574 | 250 | cstart=c = 9-((r&31)>>3); // time before gravity kicks in | |
| 8575 | 250 | } | |
| 8576 | |||
| 8577 | 3568 | break; | |
| 8578 | |||
| 8579 | case 2: // in flight | ||
| 8580 | 5956 | move(step); | |
| 8581 | |||
| 8582 |
2/2✓ Branch 0 taken 2748 times.
✓ Branch 1 taken 3208 times.
|
5956 | if(step>0) //going down |
| 8583 | { | ||
| 8584 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2748 times.
|
2748 | if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE) |
| 8585 | { | ||
| 8586 | ✗ | step=0-step; | |
| 8587 | ✗ | } | |
| 8588 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2748 times.
|
2748 | else if(COMBOTYPE(x+8,y+16)==cNOENEMY) |
| 8589 | { | ||
| 8590 | ✗ | step=0-step; | |
| 8591 | ✗ | } | |
| 8592 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2748 times.
|
2748 | else if(ispitfall(x+8,y+16)) |
| 8593 | { | ||
| 8594 | ✗ | step=0-step; | |
| 8595 | ✗ | } | |
| 8596 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2748 times.
|
2748 | else if(MAPFLAG(x+8,y+16)==mfNOENEMY) |
| 8597 | { | ||
| 8598 | ✗ | step=0-step; | |
| 8599 | ✗ | } | |
| 8600 |
1/2✓ Branch 0 taken 2748 times.
✗ Branch 1 not taken.
|
2748 | else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY) |
| 8601 | { | ||
| 8602 | ✗ | step=0-step; | |
| 8603 | ✗ | } | |
| 8604 | 2748 | } | |
| 8605 |
2/2✓ Branch 0 taken 203 times.
✓ Branch 1 taken 3005 times.
|
3208 | else if(step<0) |
| 8606 | { | ||
| 8607 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3005 times.
|
3005 | if(COMBOTYPE(x+8,y)==cNOJUMPZONE) |
| 8608 | { | ||
| 8609 | ✗ | step=0-step; | |
| 8610 | ✗ | } | |
| 8611 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3005 times.
|
3005 | else if(COMBOTYPE(x+8,y)==cNOENEMY) |
| 8612 | { | ||
| 8613 | ✗ | step=0-step; | |
| 8614 | ✗ | } | |
| 8615 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3005 times.
|
3005 | else if(ispitfall(x+8,y)) |
| 8616 | { | ||
| 8617 | ✗ | step=0-step; | |
| 8618 | ✗ | } | |
| 8619 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3005 times.
|
3005 | else if(MAPFLAG(x+8,y)==mfNOENEMY) |
| 8620 | { | ||
| 8621 | ✗ | step=0-step; | |
| 8622 | ✗ | } | |
| 8623 |
1/2✓ Branch 0 taken 3005 times.
✗ Branch 1 not taken.
|
3005 | else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY) |
| 8624 | { | ||
| 8625 | ✗ | step=0-step; | |
| 8626 | ✗ | } | |
| 8627 | 3005 | } | |
| 8628 | |||
| 8629 |
2/2✓ Branch 0 taken 3038 times.
✓ Branch 1 taken 2918 times.
|
5956 | if(clk3==left) |
| 8630 | { | ||
| 8631 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3038 times.
|
3038 | if(COMBOTYPE(x,y+8)==cNOJUMPZONE) |
| 8632 | { | ||
| 8633 | ✗ | clk3^=1; | |
| 8634 | ✗ | } | |
| 8635 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3038 times.
|
3038 | else if(COMBOTYPE(x,y+8)==cNOENEMY) |
| 8636 | { | ||
| 8637 | ✗ | clk3^=1; | |
| 8638 | ✗ | } | |
| 8639 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3038 times.
|
3038 | else if(ispitfall(x,y+8)) |
| 8640 | { | ||
| 8641 | ✗ | clk3^=1; | |
| 8642 | ✗ | } | |
| 8643 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3038 times.
|
3038 | else if(MAPFLAG(x,y+8)==mfNOENEMY) |
| 8644 | { | ||
| 8645 | ✗ | clk3^=1; | |
| 8646 | ✗ | } | |
| 8647 |
1/2✓ Branch 0 taken 3038 times.
✗ Branch 1 not taken.
|
3038 | else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY) |
| 8648 | { | ||
| 8649 | ✗ | clk3^=1; | |
| 8650 | ✗ | } | |
| 8651 | 3038 | } | |
| 8652 | else | ||
| 8653 | { | ||
| 8654 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2918 times.
|
2918 | if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE) |
| 8655 | { | ||
| 8656 | ✗ | clk3^=1; | |
| 8657 | ✗ | } | |
| 8658 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2918 times.
|
2918 | else if(COMBOTYPE(x+16,y+8)==cNOENEMY) |
| 8659 | { | ||
| 8660 | ✗ | clk3^=1; | |
| 8661 | ✗ | } | |
| 8662 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2918 times.
|
2918 | else if(ispitfall(x+16,y+8)) |
| 8663 | { | ||
| 8664 | ✗ | clk3^=1; | |
| 8665 | ✗ | } | |
| 8666 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2918 times.
|
2918 | else if(MAPFLAG(x+16,y+8)==mfNOENEMY) |
| 8667 | { | ||
| 8668 | ✗ | clk3^=1; | |
| 8669 | ✗ | } | |
| 8670 |
1/2✓ Branch 0 taken 2918 times.
✗ Branch 1 not taken.
|
2918 | else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY) |
| 8671 | { | ||
| 8672 | ✗ | clk3^=1; | |
| 8673 | ✗ | } | |
| 8674 | } | ||
| 8675 | |||
| 8676 | 5956 | --c; | |
| 8677 | |||
| 8678 |
4/4✓ Branch 0 taken 1853 times.
✓ Branch 1 taken 4103 times.
✓ Branch 2 taken 3823 times.
✓ Branch 3 taken 2133 times.
|
5956 | if(c<0 && step<zslongToFix(dstep*100)) |
| 8679 | { | ||
| 8680 | 2133 | step+=zslongToFix(dmisc3*100); | |
| 8681 | 2133 | } | |
| 8682 | |||
| 8683 | 5956 | int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0; | |
| 8684 | |||
| 8685 |
2/2✓ Branch 0 taken 5953 times.
✓ Branch 1 taken 3 times.
|
5956 | if(x<=16-nb) clk3=right; |
| 8686 | |||
| 8687 |
2/2✓ Branch 0 taken 5943 times.
✓ Branch 1 taken 13 times.
|
5956 | if(x>=224+nb) clk3=left; |
| 8688 | |||
| 8689 | 5956 | x += (clk3==left) ? -1 : 1; | |
| 8690 | |||
| 8691 |
4/4✓ Branch 0 taken 346 times.
✓ Branch 1 taken 5610 times.
✓ Branch 2 taken 133 times.
✓ Branch 3 taken 5477 times.
|
5956 | if((--clk2<=0 && y>=16-nb) || y>=144+nb) |
| 8692 | { | ||
| 8693 |
4/4✓ Branch 0 taken 24 times.
✓ Branch 1 taken 197 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 2 times.
|
479 | if(y>=144+nb && get_qr(qr_ENEMIESZAXIS)) |
| 8694 | { | ||
| 8695 | 2 | step=0-step; | |
| 8696 | 2 | y--; | |
| 8697 | 2 | } | |
| 8698 |
2/2✓ Branch 0 taken 55 times.
✓ Branch 1 taken 164 times.
|
219 | else if(zc_oldrand()%dmisc2) //land and wait |
| 8699 | { | ||
| 8700 | 164 | clk=misc=0; | |
| 8701 | 164 | } //land and jump again | |
| 8702 | else | ||
| 8703 | { | ||
| 8704 | 55 | misc=1; | |
| 8705 | 55 | clk2=0; | |
| 8706 | } | ||
| 8707 | 221 | } | |
| 8708 | |||
| 8709 | 5698 | break; | |
| 8710 | } // switch | ||
| 8711 | 15609 | } | |
| 8712 | |||
| 8713 |
4/4✓ Branch 0 taken 861 times.
✓ Branch 1 taken 17795 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 378 times.
|
18656 | if(get_qr(qr_ENEMIESZAXIS) && misc==2) |
| 8714 | { | ||
| 8715 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 378 times.
|
378 | if (moveflags & FLAG_USE_FAKE_Z) |
| 8716 | { | ||
| 8717 | ✗ | int32_t tempy = floor_y; | |
| 8718 | ✗ | fakez=zc_max(0,zc_min(clk2start-clk2,clk2)); | |
| 8719 | ✗ | floor_y = y; | |
| 8720 | ✗ | y=tempy-fakez; | |
| 8721 | ✗ | old_y = y; | |
| 8722 | ✗ | } | |
| 8723 | else | ||
| 8724 | { | ||
| 8725 | 378 | int32_t tempy = floor_y; | |
| 8726 |
6/6✓ Branch 0 taken 185 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 345 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 176 times.
|
378 | z=zc_max(0,zc_min(clk2start-clk2,clk2)); |
| 8727 | 378 | floor_y = y; | |
| 8728 | 378 | y=tempy-z; | |
| 8729 | 378 | old_y = y; | |
| 8730 | } | ||
| 8731 | 378 | } | |
| 8732 | |||
| 8733 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 18656 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
18656 | if(stunclk && (clk&31)==1) |
| 8734 | ✗ | clk=0; | |
| 8735 | |||
| 8736 | 18656 | return enemy::animate(index); | |
| 8737 | 19106 | } | |
| 8738 | |||
| 8739 | 2228 | void eTektite::drawshadow(BITMAP *dest,bool translucent) | |
| 8740 | { | ||
| 8741 |
5/6✓ Branch 0 taken 1864 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 1864 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1787 times.
✓ Branch 5 taken 77 times.
|
2228 | if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS)) |
| 8742 | 77 | return; | |
| 8743 | |||
| 8744 | 2151 | int32_t tempy=yofs; | |
| 8745 | 2151 | int32_t fdiv = frate/4; | |
| 8746 |
1/2✓ Branch 0 taken 2151 times.
✗ Branch 1 not taken.
|
2151 | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; |
| 8747 |
1/2✓ Branch 0 taken 2151 times.
✗ Branch 1 not taken.
|
2151 | int32_t f2=get_qr(qr_NEWENEMYTILES)? |
| 8748 | 2151 | efrate:((clk>=(frate>>1))?1:0); | |
| 8749 | 2151 | flip = 0; | |
| 8750 | 2151 | shadowtile = wpnsbuf[spr_shadow].tile; | |
| 8751 | |||
| 8752 |
1/2✓ Branch 0 taken 2151 times.
✗ Branch 1 not taken.
|
2151 | if(get_qr(qr_NEWENEMYTILES)) |
| 8753 | { | ||
| 8754 |
2/2✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 679 times.
|
2151 | if(misc==0) |
| 8755 | { | ||
| 8756 | 679 | shadowtile+=f2; | |
| 8757 | 679 | } | |
| 8758 |
2/2✓ Branch 0 taken 702 times.
✓ Branch 1 taken 770 times.
|
1472 | else if(misc!=1) |
| 8759 | 770 | shadowtile+=2; | |
| 8760 | 2151 | } | |
| 8761 | else | ||
| 8762 | { | ||
| 8763 | ✗ | if(misc==0) | |
| 8764 | { | ||
| 8765 | ✗ | shadowtile += f2 ? 1 : 0; | |
| 8766 | ✗ | } | |
| 8767 | ✗ | else if(misc!=1) | |
| 8768 | { | ||
| 8769 | ✗ | ++shadowtile; | |
| 8770 | ✗ | } | |
| 8771 | } | ||
| 8772 | |||
| 8773 | 2151 | yofs+=8; | |
| 8774 | |||
| 8775 |
4/4✓ Branch 0 taken 1787 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 1197 times.
✓ Branch 3 taken 590 times.
|
2151 | if(!get_qr(qr_ENEMIESZAXIS) && misc==2) |
| 8776 | { | ||
| 8777 |
6/6✓ Branch 0 taken 316 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 282 times.
✓ Branch 5 taken 253 times.
|
590 | yofs+=zc_max(0,zc_min(clk2start-clk2,clk2)); |
| 8778 | 590 | } | |
| 8779 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2151 times.
|
2151 | if(!shadow_overpit(this)) |
| 8780 | 2151 | enemy::drawshadow(dest,translucent); | |
| 8781 | 2151 | yofs=tempy; | |
| 8782 | 2228 | } | |
| 8783 | |||
| 8784 | 20583 | void eTektite::draw(BITMAP *dest) | |
| 8785 | { | ||
| 8786 | 20583 | update_enemy_frame(); | |
| 8787 | 20583 | enemy::draw(dest); | |
| 8788 | 20583 | } | |
| 8789 | |||
| 8790 | 20 | eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 8791 | 20 | { | |
| 8792 |
2/4✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
|
20 | step=zslongToFix(guysbuf[id&0xFFF].step*100); |
| 8793 | 20 | superman=1; | |
| 8794 | 20 | dir=8; | |
| 8795 | 20 | hxofs=1000; | |
| 8796 | 20 | mainguy=false; | |
| 8797 | 20 | count_enemy=false; | |
| 8798 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 8799 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 8800 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 8801 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; } |
| 8802 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width; |
| 8803 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height; |
| 8804 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz; |
| 8805 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs; |
| 8806 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs; |
| 8807 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 8808 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs; |
| 8809 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 8810 | { | ||
| 8811 | ✗ | yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 8812 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 8813 | ✗ | } | |
| 8814 | |||
| 8815 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs; |
| 8816 | 20 | } | |
| 8817 | |||
| 8818 | 6918 | bool eItemFairy::animate(int32_t index) | |
| 8819 | { | ||
| 8820 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6918 times.
|
6918 | if(switch_hooked) return enemy::animate(index); |
| 8821 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6918 times.
|
6918 | if(dying) |
| 8822 | ✗ | return Dead(index); | |
| 8823 | |||
| 8824 | //if(clk>32) | ||
| 8825 | 6918 | misc=1; | |
| 8826 | 6918 | bool w=watch; | |
| 8827 | 6918 | watch=false; | |
| 8828 | 6918 | variable_walk_8(misc?3:0,0,8,spw_floater); | |
| 8829 | 6918 | watch=w; | |
| 8830 | |||
| 8831 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 6880 times.
|
6918 | if(clk==0) |
| 8832 | { | ||
| 8833 | 38 | removearmos(x,y,ffcactivated); | |
| 8834 | 38 | } | |
| 8835 | |||
| 8836 | 6918 | return enemy::animate(index); | |
| 8837 | 6918 | } | |
| 8838 | |||
| 8839 | 13874 | void eItemFairy::draw(BITMAP *dest) | |
| 8840 | { | ||
| 8841 | //these are here to bypass compiler warnings about unused arguments | ||
| 8842 | 13874 | dest=dest; | |
| 8843 | 13874 | } | |
| 8844 | |||
| 8845 | 77 | ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 8846 | 77 | { | |
| 8847 | //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g) | ||
| 8848 |
10/20✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 77 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 77 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 77 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 77 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 77 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 77 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 77 times.
✗ Branch 19 not taken.
|
77 | floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16); |
| 8849 | 77 | dir=8; | |
| 8850 | 77 | movestatus=1; | |
| 8851 | 77 | clk=0; | |
| 8852 |
1/2✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
|
77 | step=0; |
| 8853 | //nets+720; | ||
| 8854 | 77 | SIZEflags = d->SIZEflags; | |
| 8855 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 8856 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 8857 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 8858 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 8859 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 8860 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 8861 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 8862 |
1/2✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 8863 |
1/2✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 8864 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 8865 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 8866 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 8867 | { | ||
| 8868 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 8869 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 8870 | ✗ | } | |
| 8871 | |||
| 8872 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 8873 | 77 | } | |
| 8874 | |||
| 8875 | 13302 | bool ePeahat::animate(int32_t index) | |
| 8876 | { | ||
| 8877 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 13302 times.
|
13302 | if(switch_hooked) return enemy::animate(index); |
| 8878 |
2/4✓ Branch 0 taken 13302 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13302 times.
|
13302 | if(fallclk||drownclk) return enemy::animate(index); |
| 8879 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 13302 times.
|
13302 | if(slide()) |
| 8880 | { | ||
| 8881 | ✗ | return false; | |
| 8882 | } | ||
| 8883 | |||
| 8884 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 13302 times.
|
13302 | if(dying) |
| 8885 | ✗ | return Dead(index); | |
| 8886 | |||
| 8887 |
2/2✓ Branch 0 taken 13207 times.
✓ Branch 1 taken 95 times.
|
13302 | if(clk==0) |
| 8888 | { | ||
| 8889 | 95 | removearmos(x,y,ffcactivated); | |
| 8890 | 95 | } | |
| 8891 | |||
| 8892 |
3/4✓ Branch 0 taken 13302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8007 times.
✓ Branch 3 taken 5295 times.
|
13302 | if(stunclk==0 && clk>96) |
| 8893 | 5295 | misc=1; | |
| 8894 | |||
| 8895 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 13302 times.
|
13302 | if(!watch) |
| 8896 |
2/2✓ Branch 0 taken 6575 times.
✓ Branch 1 taken 6727 times.
|
13302 | floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16); |
| 8897 | |||
| 8898 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 13302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
13302 | if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity())) |
| 8899 | { | ||
| 8900 | ✗ | if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1)); | |
| 8901 | ✗ | else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1)); | |
| 8902 | ✗ | } | |
| 8903 | |||
| 8904 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 13302 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
13302 | if(watch && get_qr(qr_PEAHATCLOCKVULN)) |
| 8905 | ✗ | superman=0; | |
| 8906 | else | ||
| 8907 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 13302 times.
|
13302 | superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0; |
| 8908 | //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z | ||
| 8909 |
2/2✓ Branch 0 taken 13292 times.
✓ Branch 1 taken 10 times.
|
13302 | if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 ) |
| 8910 | { | ||
| 8911 |
1/2✓ Branch 0 taken 13292 times.
✗ Branch 1 not taken.
|
13292 | if ( stunclk ) --stunclk; |
| 8912 | 13292 | } | |
| 8913 | 10 | else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z | |
| 8914 | //Pretty sure this was always an error. -Z ( 14FEB2019 ) | ||
| 8915 | |||
| 8916 | |||
| 8917 |
1/2✓ Branch 0 taken 13302 times.
✗ Branch 1 not taken.
|
13302 | if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts. |
| 8918 | |||
| 8919 | 13302 | return enemy::animate(index); | |
| 8920 | 13302 | } | |
| 8921 | |||
| 8922 | 10 | void ePeahat::drawshadow(BITMAP *dest, bool translucent) | |
| 8923 | { | ||
| 8924 | 10 | int32_t tempy=yofs; | |
| 8925 | 10 | flip = 0; | |
| 8926 | 10 | shadowtile = wpnsbuf[spr_shadow].tile+posframe; | |
| 8927 | |||
| 8928 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
10 | if(!get_qr(qr_ENEMIESZAXIS)) |
| 8929 | { | ||
| 8930 | 10 | yofs+=8; | |
| 8931 | 10 | yofs+=int32_t(step/zslongToFix(dstep*10)); | |
| 8932 | 10 | } | |
| 8933 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
10 | if(!shadow_overpit(this)) |
| 8934 | 10 | enemy::drawshadow(dest,translucent); | |
| 8935 | 10 | yofs=tempy; | |
| 8936 | 10 | } | |
| 8937 | |||
| 8938 | 26626 | void ePeahat::draw(BITMAP *dest) | |
| 8939 | { | ||
| 8940 | 26626 | update_enemy_frame(); | |
| 8941 | 26626 | enemy::draw(dest); | |
| 8942 | 26626 | } | |
| 8943 | |||
| 8944 | ✗ | int32_t ePeahat::takehit(weapon *w, weapon* realweap) | |
| 8945 | { | ||
| 8946 | ✗ | int32_t wpnId = w->id; | |
| 8947 | ✗ | int32_t enemyHitWeapon = w->parentitem; | |
| 8948 | |||
| 8949 | ✗ | if(dying || clk<0 || hclk>0) | |
| 8950 | ✗ | return 0; | |
| 8951 | |||
| 8952 | ✗ | if(superman && !(wpnId==wSBomb) // vulnerable to super bombs | |
| 8953 | // fire boomerang, for nailing peahats | ||
| 8954 | ✗ | && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0)) | |
| 8955 | ✗ | return 0; | |
| 8956 | |||
| 8957 | // Time for a kludge... | ||
| 8958 | ✗ | int32_t s = superman; | |
| 8959 | ✗ | superman = 0; | |
| 8960 | ✗ | int32_t ret = enemy::takehit(w,realweap); | |
| 8961 | ✗ | superman = s; | |
| 8962 | |||
| 8963 | // Anyway... | ||
| 8964 | ✗ | if(stunclk == 160) | |
| 8965 | { | ||
| 8966 | ✗ | clk2=0; | |
| 8967 | ✗ | movestatus=0; | |
| 8968 | ✗ | misc=0; | |
| 8969 | ✗ | clk=0; | |
| 8970 | ✗ | step=0; | |
| 8971 | ✗ | } | |
| 8972 | |||
| 8973 | ✗ | return ret; | |
| 8974 | ✗ | } | |
| 8975 | |||
| 8976 | // auomatically kill off enemy (for rooms with ringleaders) | ||
| 8977 | ✗ | void ePeahat::kickbucket() | |
| 8978 | { | ||
| 8979 | ✗ | hp=-1000; // don't call death_sfx() | |
| 8980 | ✗ | } | |
| 8981 | |||
| 8982 | 83 | eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 8983 | 83 | { | |
| 8984 | // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers | ||
| 8985 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 67 times.
|
83 | if(dmisc1==0) |
| 8986 | { | ||
| 8987 | 67 | misc=-1; //Line of Sight leevers | |
| 8988 | 67 | clk-=16; | |
| 8989 | 67 | } | |
| 8990 | 83 | clk3 = 0; | |
| 8991 | //nets+1460; | ||
| 8992 | 83 | temprule=(get_qr(qr_NEWENEMYTILES)) != 0; | |
| 8993 | 83 | submerged = false; | |
| 8994 | 83 | SIZEflags = d->SIZEflags; | |
| 8995 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
83 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 8996 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 8997 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 8998 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
83 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 8999 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
83 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 9000 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
83 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 9001 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
83 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 9002 |
1/2✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
|
83 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 9003 |
1/2✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
|
83 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 9004 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 9005 |
1/4✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
83 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 9006 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
|
83 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 9007 | { | ||
| 9008 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 9009 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 9010 | ✗ | } | |
| 9011 | |||
| 9012 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
83 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 9013 | 83 | } | |
| 9014 | |||
| 9015 | ✗ | bool eLeever::isSubmerged() const | |
| 9016 | { | ||
| 9017 | ✗ | Z_scripterrlog("misc is: %d\n", misc); | |
| 9018 | ✗ | return misc <= 0; | |
| 9019 | |||
| 9020 | } | ||
| 9021 | |||
| 9022 | 15176 | bool eLeever::animate(int32_t index) | |
| 9023 | { | ||
| 9024 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15176 times.
|
15176 | if(switch_hooked) return enemy::animate(index); |
| 9025 |
2/4✓ Branch 0 taken 15176 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15176 times.
|
15176 | if(fallclk||drownclk) |
| 9026 | { | ||
| 9027 | ✗ | return enemy::animate(index); | |
| 9028 | } | ||
| 9029 |
2/2✓ Branch 0 taken 688 times.
✓ Branch 1 taken 14488 times.
|
15176 | if(dying) |
| 9030 | 688 | return Dead(index); | |
| 9031 | |||
| 9032 |
2/2✓ Branch 0 taken 14165 times.
✓ Branch 1 taken 323 times.
|
14488 | if(clk==0) |
| 9033 | { | ||
| 9034 | 323 | removearmos(x,y,ffcactivated); | |
| 9035 | 323 | } | |
| 9036 | |||
| 9037 |
4/4✓ Branch 0 taken 10172 times.
✓ Branch 1 taken 4316 times.
✓ Branch 2 taken 170 times.
✓ Branch 3 taken 10002 times.
|
14488 | if(clk>=0 && !slide()) |
| 9038 | { | ||
| 9039 | // switch(d->misc1) | ||
| 9040 |
2/2✓ Branch 0 taken 7246 times.
✓ Branch 1 taken 2756 times.
|
10002 | switch(dmisc1) |
| 9041 | { | ||
| 9042 | case 0: //line of sight | ||
| 9043 | case 2: | ||
| 9044 |
7/8✗ Branch 0 not taken.
✓ Branch 1 taken 2606 times.
✓ Branch 2 taken 277 times.
✓ Branch 3 taken 1008 times.
✓ Branch 4 taken 432 times.
✓ Branch 5 taken 2823 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 64 times.
|
7246 | switch(misc) //is this leever active |
| 9045 | { | ||
| 9046 | case -1: //submerged | ||
| 9047 | { | ||
| 9048 |
4/6✓ Branch 0 taken 52 times.
✓ Branch 1 taken 2554 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 52 times.
|
2606 | if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0; |
| 9049 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2606 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2606 | if((dmisc1==2)&&(zc_oldrand()&255)) |
| 9050 | { | ||
| 9051 | ✗ | break; | |
| 9052 | } | ||
| 9053 | |||
| 9054 | 2606 | int32_t active=0; | |
| 9055 | |||
| 9056 |
2/2✓ Branch 0 taken 13753 times.
✓ Branch 1 taken 2606 times.
|
16359 | for(int32_t i=0; i<guys.Count(); i++) |
| 9057 | { | ||
| 9058 |
4/4✓ Branch 0 taken 10954 times.
✓ Branch 1 taken 2799 times.
✓ Branch 2 taken 5820 times.
✓ Branch 3 taken 5134 times.
|
13753 | if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0)) |
| 9059 | { | ||
| 9060 | 5134 | ++active; | |
| 9061 | 5134 | } | |
| 9062 | 13753 | } | |
| 9063 | |||
| 9064 |
2/2✓ Branch 0 taken 2548 times.
✓ Branch 1 taken 58 times.
|
2606 | if(active<((dmisc1==2)?1:2)) |
| 9065 | { | ||
| 9066 | 58 | misc=0; //activate this one | |
| 9067 | 58 | clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned. | |
| 9068 | 58 | } | |
| 9069 | } | ||
| 9070 | 2606 | break; | |
| 9071 | |||
| 9072 | case 0: | ||
| 9073 | { | ||
| 9074 | |||
| 9075 |
4/6✓ Branch 0 taken 45 times.
✓ Branch 1 taken 232 times.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 45 times.
|
277 | if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) |
| 9076 | { | ||
| 9077 | ✗ | misc=1; | |
| 9078 | ✗ | clk2=0; | |
| 9079 | ✗ | } | |
| 9080 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
|
277 | else if (clk3<=0) |
| 9081 | { | ||
| 9082 | ✗ | misc = -1; | |
| 9083 | ✗ | break; | |
| 9084 | } | ||
| 9085 | 277 | int32_t s=0; | |
| 9086 | |||
| 9087 |
2/2✓ Branch 0 taken 1758 times.
✓ Branch 1 taken 277 times.
|
2035 | for(int32_t i=0; i<guys.Count(); i++) |
| 9088 | { | ||
| 9089 |
4/4✓ Branch 0 taken 1229 times.
✓ Branch 1 taken 529 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 153 times.
|
1758 | if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1) |
| 9090 | { | ||
| 9091 | 153 | ++s; | |
| 9092 | 153 | } | |
| 9093 | 1758 | } | |
| 9094 | |||
| 9095 |
2/2✓ Branch 0 taken 153 times.
✓ Branch 1 taken 124 times.
|
277 | if(s>0) |
| 9096 | { | ||
| 9097 | 153 | break; | |
| 9098 | } | ||
| 9099 | |||
| 9100 | 124 | int32_t d2=zc_oldrand()&1; | |
| 9101 | |||
| 9102 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 100 times.
|
124 | if(HeroDir()>=left) |
| 9103 | { | ||
| 9104 | 100 | d2+=2; | |
| 9105 | 100 | } | |
| 9106 | |||
| 9107 |
4/4✓ Branch 0 taken 76 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 63 times.
|
124 | if(canplace(d2) || canplace(d2^1)) |
| 9108 | { | ||
| 9109 | 61 | misc=1; | |
| 9110 | 61 | clk2=0; | |
| 9111 | 61 | clk=0; | |
| 9112 | 61 | } | |
| 9113 | } | ||
| 9114 | 124 | break; | |
| 9115 | |||
| 9116 | case 1: | ||
| 9117 | |||
| 9118 |
6/8✓ Branch 0 taken 949 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 865 times.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 84 times.
|
1008 | if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2; |
| 9119 | |||
| 9120 | 1008 | break; | |
| 9121 | |||
| 9122 | case 2: | ||
| 9123 | |||
| 9124 |
6/8✓ Branch 0 taken 380 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 345 times.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 35 times.
|
432 | if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3; |
| 9125 | |||
| 9126 | 432 | break; | |
| 9127 | |||
| 9128 | // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break; | ||
| 9129 | case 3: | ||
| 9130 | |||
| 9131 |
4/6✓ Branch 0 taken 2823 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2823 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 2769 times.
|
2823 | if(stunclk || frozenclock || watch) break; |
| 9132 | |||
| 9133 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2767 times.
|
2769 | if(scored) dir^=1; |
| 9134 | |||
| 9135 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2765 times.
|
2769 | if(!canmove(dir,false)) misc=4; |
| 9136 | 2765 | else move(zslongToFix(dstep*100)); | |
| 9137 | |||
| 9138 | 2769 | break; | |
| 9139 | |||
| 9140 | case 4: | ||
| 9141 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
36 | if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2; |
| 9142 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
|
36 | if(--clk2<=16) |
| 9143 | { | ||
| 9144 | 4 | misc=5; | |
| 9145 | 4 | clk=8; | |
| 9146 | 4 | } | |
| 9147 | |||
| 9148 | 36 | break; | |
| 9149 | |||
| 9150 | case 5: | ||
| 9151 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
64 | if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1; |
| 9152 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4 times.
|
64 | if(--clk2<=0) misc=((dmisc1==2)?-1:0); |
| 9153 | |||
| 9154 | 64 | break; | |
| 9155 | } // switch(misc) | ||
| 9156 | |||
| 9157 | 7246 | break; | |
| 9158 | |||
| 9159 | default: //random | ||
| 9160 | // step=d->misc3/100.0; | ||
| 9161 | |||
| 9162 | 2756 | step=zslongToFix(dmisc3*100); | |
| 9163 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 2756 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
2756 | if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2; |
| 9164 | ✗ | else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) | |
| 9165 | { | ||
| 9166 | ✗ | if (clk2 < 48) clk2+=2; | |
| 9167 | ✗ | if (clk2 >= 300) clk2-=2; | |
| 9168 | ✗ | } | |
| 9169 | |||
| 9170 |
2/2✓ Branch 0 taken 434 times.
✓ Branch 1 taken 2322 times.
|
2756 | if(clk2<32) misc=1; |
| 9171 |
2/2✓ Branch 0 taken 224 times.
✓ Branch 1 taken 2098 times.
|
2322 | else if(clk2<48) misc=2; |
| 9172 |
1/2✓ Branch 0 taken 2098 times.
✗ Branch 1 not taken.
|
2098 | else if(clk2<300) |
| 9173 | { | ||
| 9174 | /*if(misc==2 && (int32_t)(dmisc3*0.48)%8) | ||
| 9175 | { | ||
| 9176 | fix_coords(); | ||
| 9177 | }*/ | ||
| 9178 | 2098 | misc=3; | |
| 9179 | 2098 | step = zslongToFix(dstep*100); | |
| 9180 | 2098 | } | |
| 9181 | ✗ | else if(clk2<316) misc=2; | |
| 9182 | ✗ | else if(clk2<412) misc=1; | |
| 9183 | ✗ | else if(clk2<540) | |
| 9184 | { | ||
| 9185 | ✗ | misc=0; | |
| 9186 | ✗ | step=0; | |
| 9187 | ✗ | } | |
| 9188 | ✗ | else clk2=0; | |
| 9189 | |||
| 9190 |
2/2✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 14 times.
|
2756 | if(clk2==48) clk=0; |
| 9191 | |||
| 9192 | // variable_walk(d->rate, d->homing, 0); | ||
| 9193 | 2756 | variable_walk(rate, homing, 0); | |
| 9194 | 2756 | } // switch(dmisc1) | |
| 9195 | 10002 | } | |
| 9196 | |||
| 9197 | 14488 | hxofs=(misc>=2)?0:1000; | |
| 9198 | 14488 | return enemy::animate(index); | |
| 9199 | 15176 | } | |
| 9200 | |||
| 9201 | 200 | bool eLeever::canplace(int32_t d2) | |
| 9202 | { | ||
| 9203 | 200 | int32_t nx=HeroX(); | |
| 9204 | 200 | int32_t ny=HeroY(); | |
| 9205 | |||
| 9206 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 164 times.
|
200 | if(d2<left) ny&=0xF0; |
| 9207 | 164 | else nx&=0xF0; | |
| 9208 | |||
| 9209 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 86 times.
|
200 | switch(d2) |
| 9210 | { | ||
| 9211 | // case up: ny-=((d->misc1==0)?32:48); break; | ||
| 9212 | // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break; | ||
| 9213 | // case left: nx-=((d->misc1==0)?32:48); break; | ||
| 9214 | // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break; | ||
| 9215 | case up: | ||
| 9216 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | ny-=((dmisc1==0||dmisc1==2)?32:48); |
| 9217 | 15 | break; | |
| 9218 | |||
| 9219 | case down: | ||
| 9220 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
|
21 | ny+=((dmisc1==0||dmisc1==2)?32:48); |
| 9221 | |||
| 9222 |
3/4✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
|
21 | if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0); |
| 9223 | |||
| 9224 | 21 | break; | |
| 9225 | |||
| 9226 | case left: | ||
| 9227 |
1/2✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
|
78 | nx-=((dmisc1==0||dmisc1==2)?32:48); |
| 9228 | 78 | break; | |
| 9229 | |||
| 9230 | case right: | ||
| 9231 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | nx+=((dmisc1==0||dmisc1==2)?32:48); |
| 9232 | |||
| 9233 |
3/4✓ Branch 0 taken 80 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
|
86 | if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0); |
| 9234 | |||
| 9235 | 86 | break; | |
| 9236 | } | ||
| 9237 | |||
| 9238 |
4/4✓ Branch 0 taken 174 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 120 times.
|
200 | if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/ |
| 9239 | 80 | return false; | |
| 9240 | |||
| 9241 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 100 times.
|
120 | if(d2>=left) |
| 9242 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 41 times.
|
100 | if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/ |
| 9243 | 59 | return false; | |
| 9244 | |||
| 9245 | 61 | x=nx; | |
| 9246 | 61 | y=ny; | |
| 9247 | 61 | dir=d2^1; | |
| 9248 | 61 | return true; | |
| 9249 | 200 | } | |
| 9250 | |||
| 9251 | 15185 | void eLeever::draw(BITMAP *dest) | |
| 9252 | { | ||
| 9253 | // cs=d->cset; | ||
| 9254 | 15185 | cs=dcset; | |
| 9255 | 15185 | update_enemy_frame(); | |
| 9256 |
2/4✓ Branch 0 taken 15185 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15185 times.
|
15185 | if(!fallclk&&!drownclk) |
| 9257 | { | ||
| 9258 |
2/2✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 7216 times.
|
15185 | switch(misc) |
| 9259 | { | ||
| 9260 | case -1: | ||
| 9261 | case 0: | ||
| 9262 | 7216 | return; | |
| 9263 | } | ||
| 9264 | 7969 | } | |
| 9265 | |||
| 9266 | 7969 | enemy::draw(dest); | |
| 9267 | 15185 | } | |
| 9268 | |||
| 9269 | 37 | eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 9270 | 37 | { | |
| 9271 | //zprint2("eWallM::eWallM\n"); | ||
| 9272 | 37 | hashero=false; | |
| 9273 | //nets+1000; | ||
| 9274 | 37 | SIZEflags = d->SIZEflags; | |
| 9275 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
37 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 9276 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 9277 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 9278 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
37 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 9279 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
37 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 9280 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
37 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 9281 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
37 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 9282 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 9283 |
1/2✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
|
37 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 9284 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 9285 |
1/4✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
37 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 9286 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
|
37 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 9287 | { | ||
| 9288 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 9289 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 9290 | ✗ | } | |
| 9291 | |||
| 9292 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
37 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 9293 | 37 | } | |
| 9294 | |||
| 9295 | 20622 | bool eWallM::animate(int32_t index) | |
| 9296 | { | ||
| 9297 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20622 times.
|
20622 | if(switch_hooked) return enemy::animate(index); |
| 9298 |
2/4✓ Branch 0 taken 20622 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20622 times.
|
20622 | if(fallclk||drownclk) |
| 9299 | { | ||
| 9300 | ✗ | return enemy::animate(index); | |
| 9301 | } | ||
| 9302 |
2/2✓ Branch 0 taken 252 times.
✓ Branch 1 taken 20370 times.
|
20622 | if(dying) |
| 9303 | 252 | return Dead(index); | |
| 9304 | |||
| 9305 |
2/2✓ Branch 0 taken 19126 times.
✓ Branch 1 taken 1244 times.
|
20370 | if(clk==0) |
| 9306 | { | ||
| 9307 | 1244 | removearmos(x,y,ffcactivated); | |
| 9308 | 1244 | } | |
| 9309 | |||
| 9310 | 20370 | hxofs=1000; | |
| 9311 |
2/2✓ Branch 0 taken 4474 times.
✓ Branch 1 taken 15896 times.
|
20370 | if(misc==0) //inside wall, ready to spawn? |
| 9312 | { | ||
| 9313 | //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk); | ||
| 9314 | //zprint2("frame is: %d\n",frame); | ||
| 9315 | //zprint2("wallm_load_clk is: %d\n",wallm_load_clk); | ||
| 9316 |
4/4✓ Branch 0 taken 5657 times.
✓ Branch 1 taken 10239 times.
✓ Branch 2 taken 570 times.
✓ Branch 3 taken 5087 times.
|
15896 | if(frame-wallm_load_clk>80 && clk>=0) |
| 9317 | { | ||
| 9318 | //zprint2("getting wall\n"); | ||
| 9319 | 5087 | int32_t wall=hero_on_wall(); | |
| 9320 | //zprint2("Wallmaster wall is %d\n",wall); | ||
| 9321 | 5087 | int32_t wallm_cnt=0; | |
| 9322 | |||
| 9323 |
2/2✓ Branch 0 taken 38686 times.
✓ Branch 1 taken 5087 times.
|
43773 | for(int32_t i=0; i<guys.Count(); i++) |
| 9324 |
2/2✓ Branch 0 taken 4337 times.
✓ Branch 1 taken 34349 times.
|
73035 | if(((enemy*)guys.spr(i))->family==eeWALLM) |
| 9325 | { | ||
| 9326 | 34349 | int32_t m=((enemy*)guys.spr(i))->misc; | |
| 9327 | |||
| 9328 |
4/4✓ Branch 0 taken 6388 times.
✓ Branch 1 taken 27961 times.
✓ Branch 2 taken 6381 times.
✓ Branch 3 taken 7 times.
|
34349 | if(m && ((enemy*)guys.spr(i))->clk3==(wall^1)) |
| 9329 | { | ||
| 9330 | 7 | ++wallm_cnt; | |
| 9331 | 7 | } | |
| 9332 | 34349 | } | |
| 9333 | |||
| 9334 |
2/2✓ Branch 0 taken 5058 times.
✓ Branch 1 taken 29 times.
|
5087 | if(wall>0) |
| 9335 | { | ||
| 9336 | 29 | --wall; | |
| 9337 | 29 | misc=1; //emerging from the wall? | |
| 9338 | //zprint2("Wallmaster is emerging\n"); | ||
| 9339 | 29 | clk2=0; | |
| 9340 | 29 | clk3=wall^1; | |
| 9341 | 29 | wallm_load_clk=frame; | |
| 9342 | |||
| 9343 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 11 times.
|
29 | if(wall<=down) |
| 9344 | { | ||
| 9345 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 15 times.
|
18 | if(HeroDir()==left) |
| 9346 | 3 | dir=right; | |
| 9347 | else | ||
| 9348 | 15 | dir=left; | |
| 9349 | 18 | } | |
| 9350 | else | ||
| 9351 | { | ||
| 9352 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 6 times.
|
11 | if(HeroDir()==up) |
| 9353 | 5 | dir=down; | |
| 9354 | else | ||
| 9355 | 6 | dir=up; | |
| 9356 | } | ||
| 9357 | |||
| 9358 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 1 times.
|
29 | switch(wall) |
| 9359 | { | ||
| 9360 | case up: | ||
| 9361 | 10 | y=0; | |
| 9362 | 10 | break; | |
| 9363 | |||
| 9364 | case down: | ||
| 9365 | 8 | y=160; | |
| 9366 | 8 | break; | |
| 9367 | |||
| 9368 | case left: | ||
| 9369 | 10 | x=0; | |
| 9370 | 10 | break; | |
| 9371 | |||
| 9372 | case right: | ||
| 9373 | 1 | x=240; | |
| 9374 | 1 | break; | |
| 9375 | } | ||
| 9376 | |||
| 9377 | //zprint2("Wallmaster (p1) x is %d\n",x); | ||
| 9378 | //zprint2("Wallmaster (p1) y is %d\n",y); | ||
| 9379 | |||
| 9380 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 3 times.
|
29 | switch(dir) |
| 9381 | { | ||
| 9382 | case up: | ||
| 9383 | 6 | y=(HeroY()+48-(wallm_cnt&1)*12); | |
| 9384 | 6 | flip=wall&1; | |
| 9385 | 6 | break; | |
| 9386 | |||
| 9387 | case down: | ||
| 9388 | 5 | y=(HeroY()-48+(wallm_cnt&1)*12); | |
| 9389 | 5 | flip=((wall&1)^1)+2; | |
| 9390 | 5 | break; | |
| 9391 | |||
| 9392 | case left: | ||
| 9393 | 15 | x=(HeroX()+48-(wallm_cnt&1)*12); | |
| 9394 | 15 | flip=(wall==up?2:0)+1; | |
| 9395 | 15 | break; | |
| 9396 | |||
| 9397 | case right: | ||
| 9398 | 3 | x=(HeroX()-48+(wallm_cnt&1)*12); | |
| 9399 | 3 | flip=(wall==up?2:0); | |
| 9400 | 3 | break; | |
| 9401 | } | ||
| 9402 | |||
| 9403 | //zprint2("Wallmaster (p2) x is %d\n",x); | ||
| 9404 | //zprint2("Wallmaster (p2) y is %d\n",y); | ||
| 9405 | 29 | } | |
| 9406 | 5087 | } | |
| 9407 | 15896 | } | |
| 9408 | else | ||
| 9409 | 4474 | wallm_crawl(); | |
| 9410 | |||
| 9411 | 20370 | return enemy::animate(index); | |
| 9412 | 20622 | } | |
| 9413 | |||
| 9414 | 4474 | void eWallM::wallm_crawl() | |
| 9415 | { | ||
| 9416 | 4474 | bool w=watch; | |
| 9417 | 4474 | hxofs=0; | |
| 9418 | |||
| 9419 |
2/2✓ Branch 0 taken 103 times.
✓ Branch 1 taken 4371 times.
|
4474 | if(slide()) |
| 9420 | { | ||
| 9421 | 103 | return; | |
| 9422 | } | ||
| 9423 | |||
| 9424 | // if(dying || watch || (!hashero && stunclk)) | ||
| 9425 |
4/8✓ Branch 0 taken 4371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4371 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4371 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4371 times.
|
4371 | if(dying || (!hashero && ( stunclk || frozenclock ))) |
| 9426 | { | ||
| 9427 | ✗ | return; | |
| 9428 | } | ||
| 9429 | |||
| 9430 | 4371 | watch=false; | |
| 9431 | 4371 | ++clk2; | |
| 9432 | // Misc1: slightly different movement | ||
| 9433 | //zprint2("wallmaster crawl\n"); | ||
| 9434 | //zprint2("wallmaster tmpdstep is %d\n",tmpdstep); | ||
| 9435 | 4371 | float tmpmisc3 = ((40.0/(int32_t)dstep)*40); | |
| 9436 | |||
| 9437 | //int32_t tmpmisc = int32_t((40.0/dstep)*40); | ||
| 9438 | //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc); | ||
| 9439 | //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4); | ||
| 9440 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4371 times.
|
4371 | misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1; |
| 9441 | //zprint2("wallmaster crawl misc is: %d\n", misc); | ||
| 9442 |
5/6✓ Branch 0 taken 87 times.
✓ Branch 1 taken 4284 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 75 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
|
4371 | if(w&&misc>=3&&misc<=5) |
| 9443 | { | ||
| 9444 | 12 | --clk2; | |
| 9445 | 12 | } | |
| 9446 | |||
| 9447 |
4/4✓ Branch 0 taken 1665 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 560 times.
✓ Branch 3 taken 7 times.
|
4371 | switch(misc) |
| 9448 | { | ||
| 9449 | case 1: | ||
| 9450 | case 2: | ||
| 9451 | 2139 | zc_swap(dir,clk3); | |
| 9452 | 2139 | move(step); | |
| 9453 | 2139 | zc_swap(dir,clk3); | |
| 9454 | 2139 | break; | |
| 9455 | |||
| 9456 | case 3: | ||
| 9457 | case 4: | ||
| 9458 | case 5: | ||
| 9459 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1653 times.
|
1665 | if(w) |
| 9460 | { | ||
| 9461 | 12 | watch=w; | |
| 9462 | 12 | return; | |
| 9463 | } | ||
| 9464 | |||
| 9465 | 1653 | move(step); | |
| 9466 | 1653 | break; | |
| 9467 | |||
| 9468 | case 6: | ||
| 9469 | case 7: | ||
| 9470 | 560 | zc_swap(dir,clk3); | |
| 9471 | 560 | dir^=1; | |
| 9472 | 560 | move(step); | |
| 9473 | 560 | dir^=1; | |
| 9474 | 560 | zc_swap(dir,clk3); | |
| 9475 | 560 | break; | |
| 9476 | |||
| 9477 | default: | ||
| 9478 | 7 | misc=0; | |
| 9479 | 7 | break; | |
| 9480 | } | ||
| 9481 | |||
| 9482 | 4359 | watch=w; | |
| 9483 | 4474 | } | |
| 9484 | |||
| 9485 | ✗ | void eWallM::grabhero() | |
| 9486 | { | ||
| 9487 | ✗ | hashero=true; | |
| 9488 | ✗ | superman=1; | |
| 9489 | ✗ | } | |
| 9490 | |||
| 9491 | 20622 | void eWallM::draw(BITMAP *dest) | |
| 9492 | { | ||
| 9493 | 20622 | dummy_bool[1]=hashero; | |
| 9494 | 20622 | update_enemy_frame(); | |
| 9495 | |||
| 9496 |
4/6✓ Branch 0 taken 15896 times.
✓ Branch 1 taken 4726 times.
✓ Branch 2 taken 15896 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15896 times.
|
20622 | if(misc>0 || fallclk||drownclk) |
| 9497 | { | ||
| 9498 | 4726 | masked_draw(dest,16,playing_field_offset+16,224,144); | |
| 9499 | 4726 | } | |
| 9500 | |||
| 9501 | // enemy::draw(dest); | ||
| 9502 | // tile = clk&8 ? 128:129; | ||
| 9503 | 20622 | } | |
| 9504 | |||
| 9505 | ✗ | bool eWallM::isSubmerged() const | |
| 9506 | { | ||
| 9507 | ✗ | return ( !misc ); | |
| 9508 | } | ||
| 9509 | |||
| 9510 | 48 | eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 9511 | 48 | { | |
| 9512 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | ox=x; //original x |
| 9513 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | oy=y; //original y |
| 9514 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if(get_qr(qr_TRAPPOSFIX)) |
| 9515 | { | ||
| 9516 | ✗ | yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); | |
| 9517 | ✗ | } | |
| 9518 | |||
| 9519 | 48 | mainguy=false; | |
| 9520 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
|
48 | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; |
| 9521 | //nets+420; | ||
| 9522 | 48 | dummy_int[1]=0; | |
| 9523 | 48 | SIZEflags = d->SIZEflags; | |
| 9524 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
48 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 9525 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 9526 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 9527 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
48 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 9528 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
48 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 9529 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
48 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 9530 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
48 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 9531 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 9532 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 9533 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 9534 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
48 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 9535 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
|
48 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 9536 | { | ||
| 9537 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 9538 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 9539 | ✗ | } | |
| 9540 | |||
| 9541 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
48 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 9542 | 48 | } | |
| 9543 | |||
| 9544 | 17238 | bool eTrap::animate(int32_t index) | |
| 9545 | { | ||
| 9546 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17238 times.
|
17238 | if(switch_hooked) return enemy::animate(index); |
| 9547 |
2/4✓ Branch 0 taken 17238 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17238 times.
|
17238 | if(fallclk||drownclk) return enemy::animate(index); |
| 9548 |
2/2✓ Branch 0 taken 16566 times.
✓ Branch 1 taken 672 times.
|
17238 | if(clk<0) |
| 9549 | 672 | return enemy::animate(index); | |
| 9550 | |||
| 9551 |
2/2✓ Branch 0 taken 15512 times.
✓ Branch 1 taken 1054 times.
|
16566 | if(clk==0) |
| 9552 | { | ||
| 9553 | 1054 | removearmos(x,y,ffcactivated); | |
| 9554 | 1054 | } | |
| 9555 | |||
| 9556 |
2/2✓ Branch 0 taken 6755 times.
✓ Branch 1 taken 9811 times.
|
16566 | if(misc==0) // waiting |
| 9557 | { | ||
| 9558 | 9811 | ox = x; | |
| 9559 | 9811 | oy = y; | |
| 9560 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 9561 | 9811 | double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); | |
| 9562 | |||
| 9563 |
4/4✓ Branch 0 taken 3501 times.
✓ Branch 1 taken 6310 times.
✓ Branch 2 taken 2098 times.
✓ Branch 3 taken 1403 times.
|
9811 | if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4))) |
| 9564 | { | ||
| 9565 | 1403 | dir=down; | |
| 9566 | 1403 | } | |
| 9567 |
4/4✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 2098 times.
✓ Branch 3 taken 3300 times.
|
8408 | else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4))) |
| 9568 | { | ||
| 9569 | 3300 | dir=right; | |
| 9570 | 3300 | } | |
| 9571 |
4/4✓ Branch 0 taken 3681 times.
✓ Branch 1 taken 1427 times.
✓ Branch 2 taken 2098 times.
✓ Branch 3 taken 1583 times.
|
5108 | else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4))) |
| 9572 | { | ||
| 9573 | 1583 | dir=up; | |
| 9574 | 1583 | } | |
| 9575 | else | ||
| 9576 | { | ||
| 9577 | 3525 | dir=left; | |
| 9578 | } | ||
| 9579 | |||
| 9580 | 9811 | int32_t d2=lined_up(15,true); | |
| 9581 | |||
| 9582 |
4/4✓ Branch 0 taken 4326 times.
✓ Branch 1 taken 5485 times.
✓ Branch 2 taken 15429 times.
✓ Branch 3 taken 5618 times.
|
15302 | if(((d2<left || d2 > right) && (dmisc1==1)) || |
| 9583 |
2/2✓ Branch 0 taken 3276 times.
✓ Branch 1 taken 2342 times.
|
5618 | ((d2>down) && (dmisc1==2)) || |
| 9584 |
2/2✓ Branch 0 taken 3244 times.
✓ Branch 1 taken 1456 times.
|
2342 | ((d2>right) && (!dmisc1)) || |
| 9585 |
2/2✓ Branch 0 taken 5491 times.
✓ Branch 1 taken 791 times.
|
4700 | ((d2<l_up) && (dmisc1==4)) || |
| 9586 |
3/4✓ Branch 0 taken 5491 times.
✓ Branch 1 taken 4700 times.
✓ Branch 2 taken 5491 times.
✗ Branch 3 not taken.
|
791 | ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) || |
| 9587 |
3/4✓ Branch 0 taken 5491 times.
✓ Branch 1 taken 791 times.
✓ Branch 2 taken 5491 times.
✗ Branch 3 not taken.
|
4700 | ((d2!=l_up) && (d2!=r_down) && (dmisc1==8))) |
| 9588 | { | ||
| 9589 | 35178 | d2=-1; | |
| 9590 | 35178 | } | |
| 9591 | |||
| 9592 |
3/4✓ Branch 0 taken 61 times.
✓ Branch 1 taken 5050 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
|
5111 | if(d2!=-1 && trapmove(d2)) |
| 9593 | { | ||
| 9594 | 61 | dir=d2; | |
| 9595 | 61 | misc=1; | |
| 9596 | 61 | clk2=(dir==down)?3:0; | |
| 9597 | 61 | } | |
| 9598 | 5111 | } | |
| 9599 | |||
| 9600 |
2/2✓ Branch 0 taken 9779 times.
✓ Branch 1 taken 2087 times.
|
11866 | if(misc==1) // charging |
| 9601 | { | ||
| 9602 | 2087 | clk2=(clk2+1)&3; | |
| 9603 | 2087 | step=(clk2==3)?1:2; | |
| 9604 | |||
| 9605 |
4/4✓ Branch 0 taken 2081 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 2033 times.
|
2087 | if(!trapmove(dir) || clip()) |
| 9606 | { | ||
| 9607 | 54 | misc=2; | |
| 9608 | |||
| 9609 |
1/2✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
|
54 | if(dir<l_up) |
| 9610 | { | ||
| 9611 | 54 | dir=dir^1; | |
| 9612 | 54 | } | |
| 9613 | else | ||
| 9614 | { | ||
| 9615 | ✗ | dir=dir^3; | |
| 9616 | } | ||
| 9617 | 54 | } | |
| 9618 | else | ||
| 9619 | { | ||
| 9620 | 2033 | sprite::move(step); | |
| 9621 | } | ||
| 9622 | 2087 | } | |
| 9623 | |||
| 9624 |
2/2✓ Branch 0 taken 7083 times.
✓ Branch 1 taken 4783 times.
|
11866 | if(misc==2) // retreating |
| 9625 | { | ||
| 9626 | 4783 | step=(++clk2&1)?1:0; | |
| 9627 | |||
| 9628 |
4/9✗ Branch 0 not taken.
✓ Branch 1 taken 871 times.
✓ Branch 2 taken 1587 times.
✓ Branch 3 taken 730 times.
✓ Branch 4 taken 1595 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
4783 | switch(dir) |
| 9629 | { | ||
| 9630 | case up: | ||
| 9631 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 862 times.
|
871 | if(int32_t(y)<=oy) goto trap_rest; |
| 9632 | 862 | else sprite::move(step); | |
| 9633 | |||
| 9634 | 862 | break; | |
| 9635 | |||
| 9636 | case left: | ||
| 9637 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1580 times.
|
1587 | if(int32_t(x)<=ox) goto trap_rest; |
| 9638 | 1580 | else sprite::move(step); | |
| 9639 | |||
| 9640 | 1580 | break; | |
| 9641 | |||
| 9642 | case down: | ||
| 9643 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 721 times.
|
730 | if(int32_t(y)>=oy) goto trap_rest; |
| 9644 | 721 | else sprite::move(step); | |
| 9645 | |||
| 9646 | 721 | break; | |
| 9647 | |||
| 9648 | case right: | ||
| 9649 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1588 times.
|
1595 | if(int32_t(x)>=ox) goto trap_rest; |
| 9650 | 1588 | else sprite::move(step); | |
| 9651 | |||
| 9652 | 1588 | break; | |
| 9653 | |||
| 9654 | case l_up: | ||
| 9655 | ✗ | if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest; | |
| 9656 | ✗ | else sprite::move(step); | |
| 9657 | |||
| 9658 | ✗ | break; | |
| 9659 | |||
| 9660 | case r_up: | ||
| 9661 | ✗ | if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest; | |
| 9662 | ✗ | else sprite::move(step); | |
| 9663 | |||
| 9664 | ✗ | break; | |
| 9665 | |||
| 9666 | case l_down: | ||
| 9667 | ✗ | if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest; | |
| 9668 | ✗ | else sprite::move(step); | |
| 9669 | |||
| 9670 | ✗ | break; | |
| 9671 | |||
| 9672 | case r_down: | ||
| 9673 | ✗ | if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest; | |
| 9674 | ✗ | else sprite::move(step); | |
| 9675 | |||
| 9676 | ✗ | break; | |
| 9677 | trap_rest: | ||
| 9678 | { | ||
| 9679 | 32 | x=ox; | |
| 9680 | 32 | y=oy; | |
| 9681 | 32 | misc=0; | |
| 9682 | } | ||
| 9683 | 32 | } | |
| 9684 | 4783 | } | |
| 9685 | |||
| 9686 | 11866 | return enemy::animate(index); | |
| 9687 | 12538 | } | |
| 9688 | |||
| 9689 | 2148 | bool eTrap::trapmove(int32_t ndir) | |
| 9690 | { | ||
| 9691 |
2/2✓ Branch 0 taken 656 times.
✓ Branch 1 taken 1492 times.
|
2148 | if(get_qr(qr_MEANTRAPS)) |
| 9692 | { | ||
| 9693 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 656 times.
|
656 | if(tmpscr->flags2&fFLOATTRAPS) |
| 9694 | ✗ | return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false); | |
| 9695 | |||
| 9696 | 656 | return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false); | |
| 9697 | } | ||
| 9698 | |||
| 9699 |
5/6✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1428 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
|
1492 | if(oy==80 && !(ndir==left || ndir == right)) |
| 9700 | ✗ | return false; | |
| 9701 | |||
| 9702 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1492 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1492 | if(ox==128 && !(ndir==up || ndir==down)) |
| 9703 | ✗ | return false; | |
| 9704 | |||
| 9705 |
3/4✓ Branch 0 taken 722 times.
✓ Branch 1 taken 770 times.
✓ Branch 2 taken 722 times.
✗ Branch 3 not taken.
|
1492 | if(oy<80 && ndir==up) |
| 9706 | ✗ | return false; | |
| 9707 | |||
| 9708 |
3/4✓ Branch 0 taken 706 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 706 times.
✗ Branch 3 not taken.
|
1492 | if(oy>80 && ndir==down) |
| 9709 | ✗ | return false; | |
| 9710 | |||
| 9711 |
3/4✓ Branch 0 taken 739 times.
✓ Branch 1 taken 753 times.
✓ Branch 2 taken 739 times.
✗ Branch 3 not taken.
|
1492 | if(ox<128 && ndir==left) |
| 9712 | ✗ | return false; | |
| 9713 | |||
| 9714 |
3/4✓ Branch 0 taken 753 times.
✓ Branch 1 taken 739 times.
✓ Branch 2 taken 753 times.
✗ Branch 3 not taken.
|
1492 | if(ox>128 && ndir==right) |
| 9715 | ✗ | return false; | |
| 9716 | |||
| 9717 |
5/6✓ Branch 0 taken 739 times.
✓ Branch 1 taken 753 times.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 349 times.
✓ Branch 4 taken 390 times.
✗ Branch 5 not taken.
|
1492 | if(ox<128 && oy<80 && ndir==l_up) |
| 9718 | ✗ | return false; | |
| 9719 | |||
| 9720 |
5/6✓ Branch 0 taken 739 times.
✓ Branch 1 taken 753 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 422 times.
✓ Branch 4 taken 317 times.
✗ Branch 5 not taken.
|
1492 | if(ox<128 && oy>80 && ndir==l_down) |
| 9721 | ✗ | return false; | |
| 9722 | |||
| 9723 |
5/6✓ Branch 0 taken 753 times.
✓ Branch 1 taken 739 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 421 times.
✓ Branch 4 taken 332 times.
✗ Branch 5 not taken.
|
1492 | if(ox>128 && oy<80 && ndir==r_up) |
| 9724 | ✗ | return false; | |
| 9725 | |||
| 9726 |
5/6✓ Branch 0 taken 753 times.
✓ Branch 1 taken 739 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 364 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 389 times.
|
1492 | if(ox>128 && oy>80 && ndir==r_down) |
| 9727 | ✗ | return false; | |
| 9728 | |||
| 9729 | 1492 | return true; | |
| 9730 | 2148 | } | |
| 9731 | |||
| 9732 | 2081 | bool eTrap::clip() | |
| 9733 | { | ||
| 9734 |
2/2✓ Branch 0 taken 1811 times.
✓ Branch 1 taken 270 times.
|
2081 | if(get_qr(qr_MEANPLACEDTRAPS)) |
| 9735 | { | ||
| 9736 |
2/9✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 135 times.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
270 | switch(dir) |
| 9737 | { | ||
| 9738 | case up: | ||
| 9739 | ✗ | if(y<=0) return true; | |
| 9740 | |||
| 9741 | ✗ | break; | |
| 9742 | |||
| 9743 | case down: | ||
| 9744 | ✗ | if(y>=160) return true; | |
| 9745 | |||
| 9746 | ✗ | break; | |
| 9747 | |||
| 9748 | case left: | ||
| 9749 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
|
135 | if(x<=0) return true; |
| 9750 | |||
| 9751 | 135 | break; | |
| 9752 | |||
| 9753 | case right: | ||
| 9754 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
|
135 | if(x>=240) return true; |
| 9755 | |||
| 9756 | 135 | break; | |
| 9757 | |||
| 9758 | case l_up: | ||
| 9759 | ✗ | if(y<=0||x<=0) return true; | |
| 9760 | |||
| 9761 | ✗ | break; | |
| 9762 | |||
| 9763 | case l_down: | ||
| 9764 | ✗ | if(y>=160||x<=0) return true; | |
| 9765 | |||
| 9766 | ✗ | break; | |
| 9767 | |||
| 9768 | case r_up: | ||
| 9769 | ✗ | if(y<=0||x>=240) return true; | |
| 9770 | |||
| 9771 | ✗ | break; | |
| 9772 | |||
| 9773 | case r_down: | ||
| 9774 | ✗ | if(y>=160||x>=240) return true; | |
| 9775 | |||
| 9776 | ✗ | break; | |
| 9777 | } | ||
| 9778 | |||
| 9779 | 270 | return false; | |
| 9780 | } | ||
| 9781 | else | ||
| 9782 | { | ||
| 9783 |
4/9✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
✓ Branch 2 taken 349 times.
✓ Branch 3 taken 579 times.
✓ Branch 4 taken 574 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
1811 | switch(dir) |
| 9784 | { | ||
| 9785 | case up: | ||
| 9786 |
3/4✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✓ Branch 3 taken 12 times.
|
309 | if(oy>80 && y<=86) return true; |
| 9787 | |||
| 9788 | 297 | break; | |
| 9789 | |||
| 9790 | case down: | ||
| 9791 |
3/4✓ Branch 0 taken 349 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
✓ Branch 3 taken 13 times.
|
349 | if(oy<80 && y>=80) return true; |
| 9792 | |||
| 9793 | 336 | break; | |
| 9794 | |||
| 9795 | case left: | ||
| 9796 |
3/4✓ Branch 0 taken 579 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 567 times.
✓ Branch 3 taken 12 times.
|
579 | if(ox>128 && x<=124) return true; |
| 9797 | |||
| 9798 | 567 | break; | |
| 9799 | |||
| 9800 | case right: | ||
| 9801 |
3/4✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 563 times.
✓ Branch 3 taken 11 times.
|
574 | if(ox<120 && x>=116) return true; |
| 9802 | |||
| 9803 | 563 | break; | |
| 9804 | |||
| 9805 | case l_up: | ||
| 9806 | ✗ | if(oy>80 && y<=86 && ox>128 && x<=124) return true; | |
| 9807 | |||
| 9808 | ✗ | break; | |
| 9809 | |||
| 9810 | case l_down: | ||
| 9811 | ✗ | if(oy<80 && y>=80 && ox>128 && x<=124) return true; | |
| 9812 | |||
| 9813 | ✗ | break; | |
| 9814 | |||
| 9815 | case r_up: | ||
| 9816 | ✗ | if(oy>80 && y<=86 && ox<120 && x>=116) return true; | |
| 9817 | |||
| 9818 | ✗ | break; | |
| 9819 | |||
| 9820 | case r_down: | ||
| 9821 | ✗ | if(oy<80 && y>=80 && ox<120 && x>=116) return true; | |
| 9822 | |||
| 9823 | ✗ | break; | |
| 9824 | } | ||
| 9825 | |||
| 9826 | 1763 | return false; | |
| 9827 | } | ||
| 9828 | 2081 | } | |
| 9829 | |||
| 9830 | 17246 | void eTrap::draw(BITMAP *dest) | |
| 9831 | { | ||
| 9832 | 17246 | update_enemy_frame(); | |
| 9833 | 17246 | enemy::draw(dest); | |
| 9834 | 17246 | } | |
| 9835 | |||
| 9836 | 168 | int32_t eTrap::takehit(weapon*,weapon*) | |
| 9837 | { | ||
| 9838 | 168 | return 0; | |
| 9839 | } | ||
| 9840 | |||
| 9841 | 4 | eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 9842 | 4 | { | |
| 9843 | 4 | lasthit=-1; | |
| 9844 | 4 | lasthitclk=0; | |
| 9845 | 4 | mainguy=false; | |
| 9846 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; |
| 9847 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | step=2; |
| 9848 |
3/6✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2)) |
| 9849 | { | ||
| 9850 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | dir=(x<=112)?right:left; |
| 9851 | 2 | } | |
| 9852 | else | ||
| 9853 | { | ||
| 9854 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | dir=(y<=72)?down:up; |
| 9855 | } | ||
| 9856 | |||
| 9857 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if(get_qr(qr_TRAPPOSFIX)) |
| 9858 | { | ||
| 9859 | ✗ | yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); | |
| 9860 | ✗ | } | |
| 9861 | |||
| 9862 | //nets+((id==eTRAP_LR)?540:520); | ||
| 9863 | 4 | dummy_int[1]=0; | |
| 9864 | 4 | SIZEflags = d->SIZEflags; | |
| 9865 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 9866 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 9867 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 9868 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 9869 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 9870 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 9871 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 9872 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 9873 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 9874 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 9875 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 9876 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 9877 | { | ||
| 9878 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 9879 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 9880 | ✗ | } | |
| 9881 | |||
| 9882 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 9883 | 4 | } | |
| 9884 | |||
| 9885 | 236 | bool eTrap2::animate(int32_t index) | |
| 9886 | { | ||
| 9887 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
|
236 | if(switch_hooked) return enemy::animate(index); |
| 9888 |
2/4✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 236 times.
|
236 | if(fallclk||drownclk) return enemy::animate(index); |
| 9889 |
2/2✓ Branch 0 taken 180 times.
✓ Branch 1 taken 56 times.
|
236 | if(clk<0) |
| 9890 | 56 | return enemy::animate(index); | |
| 9891 | |||
| 9892 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 168 times.
|
180 | if(clk==0) |
| 9893 | { | ||
| 9894 | 12 | removearmos(x,y,ffcactivated); | |
| 9895 | 12 | } | |
| 9896 | |||
| 9897 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
|
180 | if(!get_qr(qr_PHANTOMPLACEDTRAPS)) |
| 9898 | { | ||
| 9899 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
|
180 | if(lasthitclk>0) |
| 9900 | { | ||
| 9901 | ✗ | --lasthitclk; | |
| 9902 | ✗ | } | |
| 9903 | else | ||
| 9904 | { | ||
| 9905 | 180 | lasthit=-1; | |
| 9906 | } | ||
| 9907 | |||
| 9908 | 180 | bool hitenemy=false; | |
| 9909 | |||
| 9910 |
2/2✓ Branch 0 taken 720 times.
✓ Branch 1 taken 180 times.
|
900 | for(int32_t j=0; j<guys.Count(); j++) |
| 9911 | { | ||
| 9912 |
3/4✓ Branch 0 taken 540 times.
✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 540 times.
|
720 | if((j!=index) && (lasthit!=j)) |
| 9913 | { | ||
| 9914 |
1/2✓ Branch 0 taken 540 times.
✗ Branch 1 not taken.
|
540 | if(hit(guys.spr(j))) |
| 9915 | { | ||
| 9916 | ✗ | lasthit=j; | |
| 9917 | ✗ | lasthitclk=10; | |
| 9918 | ✗ | hitenemy=true; | |
| 9919 | ✗ | guys.spr(j)->lasthit=index; | |
| 9920 | ✗ | guys.spr(j)->lasthitclk=10; | |
| 9921 | // guys.spr(j)->dir=guys.spr(j)->dir^1; | ||
| 9922 | ✗ | } | |
| 9923 | 540 | } | |
| 9924 | 720 | } | |
| 9925 | |||
| 9926 |
4/6✓ Branch 0 taken 178 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 178 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 178 times.
|
180 | if(!trapmove(dir) || clip() || hitenemy) |
| 9927 | { | ||
| 9928 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2 | if(!trapmove(dir) || clip()) |
| 9929 | { | ||
| 9930 | 2 | lasthit=-1; | |
| 9931 | 2 | lasthitclk=0; | |
| 9932 | 2 | } | |
| 9933 | |||
| 9934 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(get_qr(qr_MORESOUNDS)) |
| 9935 | 2 | sfx(WAV_ZN1TAP,pan(int32_t(x))); | |
| 9936 | |||
| 9937 | 2 | dir=dir^1; | |
| 9938 | 2 | } | |
| 9939 | |||
| 9940 | 180 | sprite::move(step); | |
| 9941 | 180 | } | |
| 9942 | else | ||
| 9943 | { | ||
| 9944 | ✗ | if(!trapmove(dir) || clip()) | |
| 9945 | { | ||
| 9946 | ✗ | if(get_qr(qr_MORESOUNDS)) | |
| 9947 | ✗ | sfx(WAV_ZN1TAP,pan(int32_t(x))); | |
| 9948 | |||
| 9949 | ✗ | dir=dir^1; | |
| 9950 | ✗ | } | |
| 9951 | |||
| 9952 | ✗ | sprite::move(step); | |
| 9953 | } | ||
| 9954 | |||
| 9955 | 180 | return enemy::animate(index); | |
| 9956 | 236 | } | |
| 9957 | |||
| 9958 | 182 | bool eTrap2::trapmove(int32_t ndir) | |
| 9959 | { | ||
| 9960 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 182 times.
|
182 | if(tmpscr->flags2&fFLOATTRAPS) |
| 9961 | ✗ | return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false); | |
| 9962 | |||
| 9963 | 182 | return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false); | |
| 9964 | 182 | } | |
| 9965 | |||
| 9966 | 178 | bool eTrap2::clip() | |
| 9967 | { | ||
| 9968 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
|
178 | switch(dir) |
| 9969 | { | ||
| 9970 | case up: | ||
| 9971 |
1/2✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
|
36 | if(y<=0) return true; |
| 9972 | |||
| 9973 | 36 | break; | |
| 9974 | |||
| 9975 | case down: | ||
| 9976 |
1/2✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
|
52 | if(y>=160) return true; |
| 9977 | |||
| 9978 | 52 | break; | |
| 9979 | |||
| 9980 | case left: | ||
| 9981 |
1/2✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
|
45 | if(x<=0) return true; |
| 9982 | |||
| 9983 | 45 | break; | |
| 9984 | |||
| 9985 | case right: | ||
| 9986 |
1/2✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
|
45 | if(x>=240) return true; |
| 9987 | |||
| 9988 | 45 | break; | |
| 9989 | } | ||
| 9990 | |||
| 9991 | 178 | return false; | |
| 9992 | 178 | } | |
| 9993 | |||
| 9994 | 240 | void eTrap2::draw(BITMAP *dest) | |
| 9995 | { | ||
| 9996 | 240 | update_enemy_frame(); | |
| 9997 | 240 | enemy::draw(dest); | |
| 9998 | 240 | } | |
| 9999 | |||
| 10000 | ✗ | int32_t eTrap2::takehit(weapon*,weapon*) | |
| 10001 | { | ||
| 10002 | ✗ | return 0; | |
| 10003 | } | ||
| 10004 | |||
| 10005 | 18 | eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 10006 | 18 | { | |
| 10007 | //do not show "enemy appering" anim -DD | ||
| 10008 | 18 | clk=0; | |
| 10009 | 18 | mainguy=false; | |
| 10010 | 18 | clk2=-14; | |
| 10011 | //Enemy Editor Size Tab | ||
| 10012 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 10013 | 18 | else hxofs = -2; | |
| 10014 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 10015 | 18 | else hyofs = -2; | |
| 10016 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
18 | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz; |
| 10017 | 18 | else hit_width = 20; | |
| 10018 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
18 | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz; |
| 10019 | 18 | else hit_height=20; | |
| 10020 | |||
| 10021 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
18 | if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 10022 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
18 | if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 10023 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
18 | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz; |
| 10024 |
1/4✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
18 | if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 10025 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 10026 | { | ||
| 10027 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 10028 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 10029 | ✗ | } | |
| 10030 | |||
| 10031 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
18 | if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 10032 | //nets+1640; | ||
| 10033 | 18 | } | |
| 10034 | |||
| 10035 | 3753 | bool eRock::animate(int32_t index) | |
| 10036 | { | ||
| 10037 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3753 times.
|
3753 | if(switch_hooked) return enemy::animate(index); |
| 10038 |
2/4✓ Branch 0 taken 3753 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3753 times.
|
3753 | if(fallclk||drownclk) return enemy::animate(index); |
| 10039 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3753 times.
|
3753 | if(dying) |
| 10040 | ✗ | return Dead(index); | |
| 10041 | |||
| 10042 |
2/2✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 162 times.
|
3753 | if(clk==0) |
| 10043 | { | ||
| 10044 | 162 | removearmos(x,y,ffcactivated); | |
| 10045 | 162 | } | |
| 10046 | |||
| 10047 |
2/2✓ Branch 0 taken 3731 times.
✓ Branch 1 taken 22 times.
|
3753 | if(++clk2==0) // start it |
| 10048 | { | ||
| 10049 | 22 | x=zc_oldrand()&0xF0; | |
| 10050 | 22 | y=0; | |
| 10051 | 22 | clk3=0; | |
| 10052 | 22 | clk2=zc_oldrand()&15; | |
| 10053 | 22 | } | |
| 10054 | |||
| 10055 |
2/2✓ Branch 0 taken 642 times.
✓ Branch 1 taken 3111 times.
|
3753 | if(clk2>16) // move it |
| 10056 | { | ||
| 10057 |
2/2✓ Branch 0 taken 3004 times.
✓ Branch 1 taken 107 times.
|
3111 | if(clk3<=0) // start bounce |
| 10058 | { | ||
| 10059 | 107 | dir=zc_oldrand()&1; | |
| 10060 | |||
| 10061 |
2/2✓ Branch 0 taken 87 times.
✓ Branch 1 taken 20 times.
|
107 | if(x<32) dir=1; |
| 10062 | |||
| 10063 |
2/2✓ Branch 0 taken 97 times.
✓ Branch 1 taken 10 times.
|
107 | if(x>208) dir=0; |
| 10064 | 107 | } | |
| 10065 | |||
| 10066 |
2/2✓ Branch 0 taken 3012 times.
✓ Branch 1 taken 99 times.
|
3111 | if(clk3<13+16) |
| 10067 | { | ||
| 10068 | 3012 | x += dir ? 1 : -1; //right, left | |
| 10069 | 3012 | dummy_int[1]=dir; | |
| 10070 | |||
| 10071 |
2/2✓ Branch 0 taken 214 times.
✓ Branch 1 taken 2798 times.
|
3012 | if(clk3<2) |
| 10072 | { | ||
| 10073 | 214 | y-=2; //up | |
| 10074 | 214 | dummy_int[2]=(dummy_int[1]==1)?r_up:l_up; | |
| 10075 | 214 | } | |
| 10076 |
2/2✓ Branch 0 taken 321 times.
✓ Branch 1 taken 2477 times.
|
2798 | else if(clk3<5) |
| 10077 | { | ||
| 10078 | 321 | y--; //up | |
| 10079 | 321 | dummy_int[2]=(dummy_int[1]==1)?r_up:l_up; | |
| 10080 | 321 | } | |
| 10081 |
2/2✓ Branch 0 taken 318 times.
✓ Branch 1 taken 2159 times.
|
2477 | else if(clk3<8) |
| 10082 | { | ||
| 10083 | 318 | dummy_int[2]=(dummy_int[1]==1)?right:left; | |
| 10084 | 318 | } | |
| 10085 |
2/2✓ Branch 0 taken 315 times.
✓ Branch 1 taken 1844 times.
|
2159 | else if(clk3<11) |
| 10086 | { | ||
| 10087 | 315 | y++; //down | |
| 10088 | 315 | dummy_int[2]=(dummy_int[1]==1)?r_down:l_down; | |
| 10089 | 315 | } | |
| 10090 | else | ||
| 10091 | { | ||
| 10092 | 1844 | y+=2; //down | |
| 10093 | 1844 | dummy_int[2]=(dummy_int[1]==1)?r_down:l_down; | |
| 10094 | } | ||
| 10095 | |||
| 10096 | 3012 | ++clk3; | |
| 10097 | 3012 | } | |
| 10098 |
2/2✓ Branch 0 taken 89 times.
✓ Branch 1 taken 10 times.
|
99 | else if(y<176) |
| 10099 | 89 | clk3=0; // next bounce | |
| 10100 | else | ||
| 10101 | 10 | clk2 = -(zc_oldrand()&63); // back to top | |
| 10102 | 3111 | } | |
| 10103 | |||
| 10104 | 3753 | return enemy::animate(index); | |
| 10105 | 3753 | } | |
| 10106 | |||
| 10107 | ✗ | void eRock::drawshadow(BITMAP *dest, bool translucent) | |
| 10108 | { | ||
| 10109 | ✗ | if(clk2>=0) | |
| 10110 | { | ||
| 10111 | ✗ | int32_t tempy=yofs; | |
| 10112 | ✗ | flip = 0; | |
| 10113 | ✗ | int32_t fdiv = frate/4; | |
| 10114 | ✗ | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; | |
| 10115 | ✗ | int32_t f2=get_qr(qr_NEWENEMYTILES)? | |
| 10116 | ✗ | efrate:((clk>=(frate>>1))?1:0); | |
| 10117 | ✗ | shadowtile = wpnsbuf[spr_shadow].tile+f2; | |
| 10118 | |||
| 10119 | ✗ | yofs+=8; | |
| 10120 | ✗ | yofs+=zc_max(0,zc_min(29-clk3,clk3)); | |
| 10121 | ✗ | if(!shadow_overpit(this)) | |
| 10122 | ✗ | enemy::drawshadow(dest, translucent); | |
| 10123 | ✗ | yofs=tempy; | |
| 10124 | ✗ | } | |
| 10125 | ✗ | } | |
| 10126 | |||
| 10127 | 3753 | void eRock::draw(BITMAP *dest) | |
| 10128 | { | ||
| 10129 |
4/6✓ Branch 0 taken 472 times.
✓ Branch 1 taken 3281 times.
✓ Branch 2 taken 472 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 472 times.
|
3753 | if(clk2>=0 || fallclk||drownclk) |
| 10130 | { | ||
| 10131 | 3281 | int32_t tempdir=dir; | |
| 10132 | 3281 | dir=dummy_int[2]; | |
| 10133 | 3281 | update_enemy_frame(); | |
| 10134 | 3281 | enemy::draw(dest); | |
| 10135 | 3281 | dir=tempdir; | |
| 10136 | 3281 | } | |
| 10137 | 3753 | } | |
| 10138 | |||
| 10139 | ✗ | int32_t eRock::takehit(weapon*,weapon*) | |
| 10140 | { | ||
| 10141 | ✗ | return 0; | |
| 10142 | } | ||
| 10143 | |||
| 10144 | ✗ | eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 10145 | ✗ | { | |
| 10146 | ✗ | clk=0; | |
| 10147 | ✗ | mainguy=false; | |
| 10148 | ✗ | clk2=-14; | |
| 10149 | ✗ | if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; | |
| 10150 | ✗ | else hxofs= -10; | |
| 10151 | ✗ | if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; | |
| 10152 | ✗ | else hyofs=-10; | |
| 10153 | ✗ | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz; | |
| 10154 | ✗ | else hit_width=36; | |
| 10155 | ✗ | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz; | |
| 10156 | ✗ | else hit_height=36; | |
| 10157 | ✗ | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz; | |
| 10158 | ✗ | else hzsz=16; //can't be jumped | |
| 10159 | |||
| 10160 | ✗ | if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. | |
| 10161 | ✗ | if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } | |
| 10162 | ✗ | if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz; | |
| 10163 | ✗ | if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; | |
| 10164 | ✗ | if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) | |
| 10165 | { | ||
| 10166 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 10167 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 10168 | ✗ | } | |
| 10169 | |||
| 10170 | ✗ | if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; | |
| 10171 | //nets+1680; | ||
| 10172 | ✗ | } | |
| 10173 | |||
| 10174 | ✗ | bool eBoulder::animate(int32_t index) | |
| 10175 | { | ||
| 10176 | ✗ | if(switch_hooked) return enemy::animate(index); | |
| 10177 | ✗ | if(fallclk||drownclk) return enemy::animate(index); | |
| 10178 | ✗ | if(dying) | |
| 10179 | ✗ | return Dead(index); | |
| 10180 | |||
| 10181 | ✗ | if(clk==0) | |
| 10182 | { | ||
| 10183 | ✗ | removearmos(x,y,ffcactivated); | |
| 10184 | ✗ | } | |
| 10185 | |||
| 10186 | zfix *vert; | ||
| 10187 | ✗ | vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y; | |
| 10188 | |||
| 10189 | ✗ | if(++clk2==0) // start it | |
| 10190 | { | ||
| 10191 | ✗ | x=zc_oldrand()&0xF0; | |
| 10192 | ✗ | y=-32; | |
| 10193 | ✗ | clk3=0; | |
| 10194 | ✗ | clk2=zc_oldrand()&15; | |
| 10195 | ✗ | } | |
| 10196 | |||
| 10197 | ✗ | if(clk2>16) // move it | |
| 10198 | { | ||
| 10199 | ✗ | if(clk3<=0) // start bounce | |
| 10200 | { | ||
| 10201 | ✗ | dir=zc_oldrand()&1; | |
| 10202 | |||
| 10203 | ✗ | if(x<32) dir=1; | |
| 10204 | |||
| 10205 | ✗ | if(x>208) dir=0; | |
| 10206 | ✗ | } | |
| 10207 | |||
| 10208 | ✗ | if(clk3<13+16) | |
| 10209 | { | ||
| 10210 | ✗ | x += dir ? 1 : -1; //right, left | |
| 10211 | ✗ | dummy_int[1]=dir; | |
| 10212 | |||
| 10213 | ✗ | if(clk3<2) | |
| 10214 | { | ||
| 10215 | ✗ | y-=2; //up | |
| 10216 | ✗ | dummy_int[2]=(dummy_int[1]==1)?r_up:l_up; | |
| 10217 | ✗ | } | |
| 10218 | ✗ | else if(clk3<5) | |
| 10219 | { | ||
| 10220 | ✗ | y--; //up | |
| 10221 | ✗ | dummy_int[2]=(dummy_int[1]==1)?r_up:l_up; | |
| 10222 | ✗ | } | |
| 10223 | ✗ | else if(clk3<8) | |
| 10224 | { | ||
| 10225 | ✗ | dummy_int[2]=(dummy_int[1]==1)?right:left; | |
| 10226 | ✗ | } | |
| 10227 | ✗ | else if(clk3<11) | |
| 10228 | { | ||
| 10229 | ✗ | y++; //down | |
| 10230 | ✗ | dummy_int[2]=(dummy_int[1]==1)?r_down:l_down; | |
| 10231 | ✗ | } | |
| 10232 | else | ||
| 10233 | { | ||
| 10234 | ✗ | y+=2; //down | |
| 10235 | ✗ | dummy_int[2]=(dummy_int[1]==1)?r_down:l_down; | |
| 10236 | } | ||
| 10237 | |||
| 10238 | ✗ | ++clk3; | |
| 10239 | ✗ | } | |
| 10240 | ✗ | else if(y<176) | |
| 10241 | ✗ | clk3=0; // next bounce | |
| 10242 | else | ||
| 10243 | ✗ | clk2 = -(zc_oldrand()&63); // back to top | |
| 10244 | ✗ | } | |
| 10245 | |||
| 10246 | ✗ | return enemy::animate(index); | |
| 10247 | ✗ | } | |
| 10248 | |||
| 10249 | ✗ | void eBoulder::drawshadow(BITMAP *dest, bool translucent) | |
| 10250 | { | ||
| 10251 | ✗ | if(clk2>=0) | |
| 10252 | { | ||
| 10253 | ✗ | int32_t tempy=yofs; | |
| 10254 | ✗ | flip = 0; | |
| 10255 | ✗ | int32_t f2=((clk<<2)/frate)<<1; | |
| 10256 | ✗ | shadowtile = wpnsbuf[spr_shadow].tile+f2; | |
| 10257 | ✗ | yofs+=zc_max(0,zc_min(29-clk3,clk3)); | |
| 10258 | |||
| 10259 | ✗ | yofs+=8; | |
| 10260 | ✗ | xofs-=8; | |
| 10261 | ✗ | if(!shadow_overpit(this)) | |
| 10262 | ✗ | enemy::drawshadow(dest, translucent); | |
| 10263 | ✗ | xofs+=16; | |
| 10264 | ✗ | ++shadowtile; | |
| 10265 | ✗ | if(!shadow_overpit(this)) | |
| 10266 | ✗ | enemy::drawshadow(dest, translucent); | |
| 10267 | ✗ | yofs+=16; | |
| 10268 | ✗ | shadowtile+=20; | |
| 10269 | ✗ | if(!shadow_overpit(this)) | |
| 10270 | ✗ | enemy::drawshadow(dest, translucent); | |
| 10271 | ✗ | xofs-=16; | |
| 10272 | ✗ | --shadowtile; | |
| 10273 | ✗ | if(!shadow_overpit(this)) | |
| 10274 | ✗ | enemy::drawshadow(dest, translucent); | |
| 10275 | ✗ | xofs+=8; | |
| 10276 | ✗ | yofs=tempy; | |
| 10277 | ✗ | } | |
| 10278 | ✗ | } | |
| 10279 | |||
| 10280 | ✗ | void eBoulder::draw(BITMAP *dest) | |
| 10281 | { | ||
| 10282 | ✗ | if(clk2>=0 || fallclk||drownclk) | |
| 10283 | { | ||
| 10284 | ✗ | int32_t tempdir=dir; | |
| 10285 | ✗ | dir=dummy_int[2]; | |
| 10286 | ✗ | update_enemy_frame(); | |
| 10287 | ✗ | dir=tempdir; | |
| 10288 | ✗ | xofs-=8; | |
| 10289 | ✗ | yofs-=8; | |
| 10290 | ✗ | drawblock(dest,15); | |
| 10291 | ✗ | xofs+=8; | |
| 10292 | ✗ | yofs+=8; | |
| 10293 | // enemy::draw(dest); | ||
| 10294 | ✗ | } | |
| 10295 | ✗ | } | |
| 10296 | |||
| 10297 | ✗ | int32_t eBoulder::takehit(weapon*,weapon*) | |
| 10298 | { | ||
| 10299 | ✗ | return 0; | |
| 10300 | } | ||
| 10301 | |||
| 10302 | 77 | eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk), | |
| 10303 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
|
77 | minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk) |
| 10304 | 77 | { | |
| 10305 | /* fixing | ||
| 10306 | hp=1; | ||
| 10307 | */ | ||
| 10308 | 77 | mainguy=false; | |
| 10309 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
|
77 | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; |
| 10310 | 77 | hclk=clk; // the "no fire" range | |
| 10311 | 77 | clk=0; | |
| 10312 | 77 | clk3=96; | |
| 10313 | 77 | timer=0; | |
| 10314 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
|
77 | if(o_tile==0) |
| 10315 | { | ||
| 10316 | 77 | superman=1; | |
| 10317 | 77 | hxofs=1000; | |
| 10318 | 77 | } | |
| 10319 | 77 | SIZEflags = d->SIZEflags; | |
| 10320 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 10321 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 10322 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 10323 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 10324 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 10325 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 10326 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 10327 |
1/2✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 10328 |
1/2✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 10329 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 10330 |
1/4✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 10331 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 10332 | { | ||
| 10333 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 10334 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 10335 | ✗ | } | |
| 10336 | |||
| 10337 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; |
| 10338 | 77 | } | |
| 10339 | |||
| 10340 | 34642 | bool eProjectile::animate(int32_t index) | |
| 10341 | { | ||
| 10342 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34642 times.
|
34642 | if(switch_hooked) return enemy::animate(index); |
| 10343 |
2/4✓ Branch 0 taken 34642 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34642 times.
|
34642 | if(fallclk||drownclk) return enemy::animate(index); |
| 10344 |
2/2✓ Branch 0 taken 34461 times.
✓ Branch 1 taken 181 times.
|
34642 | if(clk==0) |
| 10345 | { | ||
| 10346 | 181 | removearmos(x,y,ffcactivated); | |
| 10347 | 181 | } | |
| 10348 | |||
| 10349 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 10350 | 34642 | double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); | |
| 10351 | |||
| 10352 |
4/4✓ Branch 0 taken 12098 times.
✓ Branch 1 taken 22544 times.
✓ Branch 2 taken 4619 times.
✓ Branch 3 taken 7479 times.
|
34642 | if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4))) |
| 10353 | { | ||
| 10354 | 7479 | dir=down; | |
| 10355 | 7479 | } | |
| 10356 |
4/4✓ Branch 0 taken 18853 times.
✓ Branch 1 taken 8310 times.
✓ Branch 2 taken 4619 times.
✓ Branch 3 taken 14234 times.
|
27163 | else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4))) |
| 10357 | { | ||
| 10358 | 14234 | dir=right; | |
| 10359 | 14234 | } | |
| 10360 |
4/4✓ Branch 0 taken 8160 times.
✓ Branch 1 taken 4769 times.
✓ Branch 2 taken 4619 times.
✓ Branch 3 taken 3541 times.
|
12929 | else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4))) |
| 10361 | { | ||
| 10362 | 3541 | dir=up; | |
| 10363 | 3541 | } | |
| 10364 | else | ||
| 10365 | { | ||
| 10366 | 9388 | dir=left; | |
| 10367 | } | ||
| 10368 | |||
| 10369 |
3/4✓ Branch 0 taken 34642 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18686 times.
✓ Branch 3 taken 15956 times.
|
34642 | if(!stunclk && ++clk3>80) |
| 10370 | { | ||
| 10371 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15956 times.
|
15956 | if(dmisc1==9) // Breath type |
| 10372 | { | ||
| 10373 | ✗ | if(timer==0) | |
| 10374 | { | ||
| 10375 | ✗ | unsigned r=zc_oldrand(); | |
| 10376 | |||
| 10377 | ✗ | if(!(r&63)) | |
| 10378 | { | ||
| 10379 | ✗ | timer=zc_oldrand()%50+50; | |
| 10380 | ✗ | } | |
| 10381 | ✗ | } | |
| 10382 | |||
| 10383 | ✗ | if(timer>0) | |
| 10384 | { | ||
| 10385 | ✗ | if(timer%4==0) | |
| 10386 | { | ||
| 10387 | ✗ | FireBreath(false); | |
| 10388 | ✗ | } | |
| 10389 | |||
| 10390 | ✗ | if(--timer==0) | |
| 10391 | { | ||
| 10392 | ✗ | clk3=0; | |
| 10393 | ✗ | } | |
| 10394 | ✗ | } | |
| 10395 | ✗ | } | |
| 10396 | |||
| 10397 | else // Not breath type | ||
| 10398 | { | ||
| 10399 | 15956 | unsigned r=zc_oldrand(); | |
| 10400 | |||
| 10401 |
4/4✓ Branch 0 taken 261 times.
✓ Branch 1 taken 15695 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 253 times.
|
15956 | if(!(r&63) && !HeroInRange(minRange)) |
| 10402 | { | ||
| 10403 | 253 | FireWeapon(); | |
| 10404 | |||
| 10405 |
1/4✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
253 | if(get_qr(qr_BROKENSTATUES)==0 && |
| 10406 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
253 | ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL)) |
| 10407 | { | ||
| 10408 |
2/2✓ Branch 0 taken 240 times.
✓ Branch 1 taken 13 times.
|
253 | if(!((r>>7)&15)) |
| 10409 | { | ||
| 10410 | 13 | x-=4; | |
| 10411 | 13 | FireWeapon(); | |
| 10412 | 13 | x+=4; | |
| 10413 | 13 | } | |
| 10414 | 253 | } | |
| 10415 | |||
| 10416 | 253 | clk3=0; | |
| 10417 | 253 | } | |
| 10418 | } | ||
| 10419 | 15956 | } | |
| 10420 | |||
| 10421 | 34642 | return enemy::animate(index); | |
| 10422 | 34642 | } | |
| 10423 | |||
| 10424 | 34635 | void eProjectile::draw(BITMAP *dest) | |
| 10425 | { | ||
| 10426 | 34635 | update_enemy_frame(); | |
| 10427 | 34635 | enemy::draw(dest); | |
| 10428 | 34635 | } | |
| 10429 | |||
| 10430 | 2 | eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 10431 | 2 | { | |
| 10432 | 2 | hxofs=1000; | |
| 10433 | 2 | } | |
| 10434 | |||
| 10435 | 162 | void eTrigger::draw(BITMAP *dest) | |
| 10436 | { | ||
| 10437 | 162 | update_enemy_frame(); | |
| 10438 | 162 | enemy::draw(dest); | |
| 10439 | 162 | } | |
| 10440 | |||
| 10441 | ✗ | void eTrigger::death_sfx() | |
| 10442 | { | ||
| 10443 | //silent death | ||
| 10444 | ✗ | } | |
| 10445 | |||
| 10446 | ✗ | eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 10447 | ✗ | { | |
| 10448 | ✗ | o_tile+=wpnsbuf[iwNPCs].tile; | |
| 10449 | ✗ | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; | |
| 10450 | ✗ | SIZEflags = d->SIZEflags; | |
| 10451 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. | |
| 10452 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 10453 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 10454 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } | |
| 10455 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; | |
| 10456 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; | |
| 10457 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; | |
| 10458 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; | |
| 10459 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; | |
| 10460 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 10461 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; | |
| 10462 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) | |
| 10463 | { | ||
| 10464 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 10465 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 10466 | ✗ | } | |
| 10467 | |||
| 10468 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; | |
| 10469 | ✗ | } | |
| 10470 | |||
| 10471 | ✗ | bool eNPC::animate(int32_t index) | |
| 10472 | { | ||
| 10473 | ✗ | if(switch_hooked) return enemy::animate(index); | |
| 10474 | ✗ | if(dying) | |
| 10475 | ✗ | return Dead(index); | |
| 10476 | |||
| 10477 | ✗ | if(clk==0) | |
| 10478 | { | ||
| 10479 | ✗ | removearmos(x,y,ffcactivated); | |
| 10480 | ✗ | } | |
| 10481 | |||
| 10482 | ✗ | switch(dmisc2) | |
| 10483 | { | ||
| 10484 | case 0: | ||
| 10485 | { | ||
| 10486 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 10487 | ✗ | double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); | |
| 10488 | |||
| 10489 | ✗ | if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4))) | |
| 10490 | { | ||
| 10491 | ✗ | dir=down; | |
| 10492 | ✗ | } | |
| 10493 | |||
| 10494 | ✗ | else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4))) | |
| 10495 | { | ||
| 10496 | ✗ | dir=right; | |
| 10497 | ✗ | } | |
| 10498 | ✗ | else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8))) | |
| 10499 | { | ||
| 10500 | ✗ | dir=up; | |
| 10501 | ✗ | } | |
| 10502 | else | ||
| 10503 | { | ||
| 10504 | ✗ | dir=left; | |
| 10505 | } | ||
| 10506 | } | ||
| 10507 | ✗ | break; | |
| 10508 | |||
| 10509 | case 1: | ||
| 10510 | ✗ | halting_walk(rate, homing, 0, hrate, 48); | |
| 10511 | |||
| 10512 | ✗ | if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15)) | |
| 10513 | { | ||
| 10514 | ✗ | newdir(rate, homing, 0); | |
| 10515 | ✗ | clk2=48; | |
| 10516 | ✗ | ++misc; | |
| 10517 | ✗ | } | |
| 10518 | |||
| 10519 | ✗ | if(clk2==0) | |
| 10520 | ✗ | misc=0; | |
| 10521 | |||
| 10522 | ✗ | break; | |
| 10523 | } | ||
| 10524 | |||
| 10525 | ✗ | return enemy::animate(index); | |
| 10526 | ✗ | } | |
| 10527 | |||
| 10528 | ✗ | void eNPC::draw(BITMAP *dest) | |
| 10529 | { | ||
| 10530 | ✗ | update_enemy_frame(); | |
| 10531 | ✗ | enemy::draw(dest); | |
| 10532 | ✗ | } | |
| 10533 | |||
| 10534 | ✗ | int32_t eNPC::takehit(weapon*,weapon*) | |
| 10535 | { | ||
| 10536 | ✗ | return 0; | |
| 10537 | } | ||
| 10538 | |||
| 10539 | ✗ | eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 10540 | ✗ | { | |
| 10541 | ✗ | if(clk>0) // clk>0 when created by a Spinning Tile combo | |
| 10542 | { | ||
| 10543 | ✗ | o_tile=clk; | |
| 10544 | ✗ | cs=id>>12; | |
| 10545 | ✗ | } | |
| 10546 | |||
| 10547 | ✗ | id=id&0xFFF; | |
| 10548 | ✗ | clk=0; | |
| 10549 | ✗ | step=0; | |
| 10550 | ✗ | mainguy=false; | |
| 10551 | ✗ | SIZEflags = d->SIZEflags; | |
| 10552 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. | |
| 10553 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 10554 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 10555 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } | |
| 10556 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; | |
| 10557 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; | |
| 10558 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; | |
| 10559 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; | |
| 10560 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; | |
| 10561 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 10562 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; | |
| 10563 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) | |
| 10564 | { | ||
| 10565 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 10566 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 10567 | ✗ | } | |
| 10568 | |||
| 10569 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; | |
| 10570 | ✗ | } | |
| 10571 | |||
| 10572 | ✗ | void eSpinTile::facehero() | |
| 10573 | { | ||
| 10574 | ✗ | if(Hero.x-x==0) | |
| 10575 | { | ||
| 10576 | ✗ | if (Hero.y + 8 < y) | |
| 10577 | ✗ | dir = up; | |
| 10578 | else | ||
| 10579 | ✗ | dir = down; | |
| 10580 | ✗ | } | |
| 10581 | else | ||
| 10582 | { | ||
| 10583 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 10584 | ✗ | double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); | |
| 10585 | |||
| 10586 | ✗ | if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0)) | |
| 10587 | { | ||
| 10588 | ✗ | dir=l_down; | |
| 10589 | ✗ | } | |
| 10590 | ✗ | else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0)) | |
| 10591 | { | ||
| 10592 | ✗ | dir=down; | |
| 10593 | ✗ | } | |
| 10594 | ✗ | else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0)) | |
| 10595 | { | ||
| 10596 | ✗ | dir=r_down; | |
| 10597 | ✗ | } | |
| 10598 | ✗ | else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0)) | |
| 10599 | { | ||
| 10600 | ✗ | dir=right; | |
| 10601 | ✗ | } | |
| 10602 | ✗ | else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0)) | |
| 10603 | { | ||
| 10604 | ✗ | dir=r_up; | |
| 10605 | ✗ | } | |
| 10606 | ✗ | else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0)) | |
| 10607 | { | ||
| 10608 | ✗ | dir=up; | |
| 10609 | ✗ | } | |
| 10610 | ✗ | else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0)) | |
| 10611 | { | ||
| 10612 | ✗ | dir=l_up; | |
| 10613 | ✗ | } | |
| 10614 | else | ||
| 10615 | { | ||
| 10616 | ✗ | dir=left; | |
| 10617 | } | ||
| 10618 | } | ||
| 10619 | ✗ | } | |
| 10620 | |||
| 10621 | |||
| 10622 | ✗ | bool eSpinTile::animate(int32_t index) | |
| 10623 | { | ||
| 10624 | ✗ | if(switch_hooked) return enemy::animate(index); | |
| 10625 | ✗ | if(fallclk||drownclk) return enemy::animate(index); | |
| 10626 | ✗ | if(dying) | |
| 10627 | { | ||
| 10628 | ✗ | return Dead(index); | |
| 10629 | } | ||
| 10630 | |||
| 10631 | ✗ | if(clk==0) | |
| 10632 | { | ||
| 10633 | ✗ | removearmos(x,y,ffcactivated); | |
| 10634 | ✗ | } | |
| 10635 | |||
| 10636 | ✗ | ++misc; | |
| 10637 | |||
| 10638 | ✗ | if(misc==96) | |
| 10639 | { | ||
| 10640 | ✗ | facehero(); | |
| 10641 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 10642 | ✗ | double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x)); | |
| 10643 | ✗ | angular=true; | |
| 10644 | ✗ | angle=ddir; | |
| 10645 | ✗ | step=zslongToFix(dstep*100); | |
| 10646 | ✗ | } | |
| 10647 | |||
| 10648 | ✗ | if(y>186 || y<=-16 || x>272 || x<=-16) | |
| 10649 | ✗ | kickbucket(); | |
| 10650 | |||
| 10651 | ✗ | sprite::move(step); | |
| 10652 | ✗ | return enemy::animate(index); | |
| 10653 | ✗ | } | |
| 10654 | |||
| 10655 | ✗ | void eSpinTile::draw(BITMAP *dest) | |
| 10656 | { | ||
| 10657 | ✗ | update_enemy_frame(); | |
| 10658 | ✗ | y-=(misc>>4); | |
| 10659 | ✗ | yofs+=2; | |
| 10660 | ✗ | enemy::draw(dest); | |
| 10661 | ✗ | yofs-=2; | |
| 10662 | ✗ | y+=(misc>>4); | |
| 10663 | ✗ | } | |
| 10664 | |||
| 10665 | ✗ | void eSpinTile::drawshadow(BITMAP *dest, bool translucent) | |
| 10666 | { | ||
| 10667 | ✗ | flip = 0; | |
| 10668 | ✗ | shadowtile = wpnsbuf[spr_shadow].tile+(clk%4); | |
| 10669 | ✗ | yofs+=4; | |
| 10670 | ✗ | if(!shadow_overpit(this)) | |
| 10671 | ✗ | enemy::drawshadow(dest, translucent); | |
| 10672 | ✗ | yofs-=4; | |
| 10673 | ✗ | } | |
| 10674 | |||
| 10675 | 94 | eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0) | |
| 10676 | 94 | { | |
| 10677 | //these are here to bypass compiler warnings about unused arguments | ||
| 10678 | 94 | Clk=Clk; | |
| 10679 | 94 | mainguy=false; | |
| 10680 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
|
94 | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; |
| 10681 | /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))])) | ||
| 10682 | { | ||
| 10683 | clk=1; | ||
| 10684 | }*/ | ||
| 10685 | //nets+880; | ||
| 10686 | 94 | SIZEflags = d->SIZEflags; | |
| 10687 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
94 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 10688 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 10689 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 10690 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
94 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 10691 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
94 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 10692 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
94 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 10693 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
94 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 10694 |
1/2✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
|
94 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 10695 |
1/2✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
|
94 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 10696 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 10697 |
1/4✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
94 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 10698 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
|
94 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 10699 | { | ||
| 10700 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 10701 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 10702 | ✗ | } | |
| 10703 | |||
| 10704 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
94 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; |
| 10705 | 94 | } | |
| 10706 | |||
| 10707 | 2543 | void eZora::facehero() | |
| 10708 | { | ||
| 10709 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2539 times.
|
2543 | if(Hero.x-x==0) |
| 10710 | { | ||
| 10711 | 4 | dir=(Hero.y+8<y)?up:down; | |
| 10712 | 4 | } | |
| 10713 | else | ||
| 10714 | { | ||
| 10715 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 10716 | 2539 | double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); | |
| 10717 | |||
| 10718 |
4/4✓ Branch 0 taken 528 times.
✓ Branch 1 taken 2011 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 272 times.
|
2539 | if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) |
| 10719 | { | ||
| 10720 | 272 | dir=l_down; | |
| 10721 | 272 | } | |
| 10722 |
4/4✓ Branch 0 taken 626 times.
✓ Branch 1 taken 1641 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 370 times.
|
2267 | else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8))) |
| 10723 | { | ||
| 10724 | 370 | dir=down; | |
| 10725 | 370 | } | |
| 10726 |
4/4✓ Branch 0 taken 614 times.
✓ Branch 1 taken 1283 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 358 times.
|
1897 | else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8))) |
| 10727 | { | ||
| 10728 | 358 | dir=r_down; | |
| 10729 | 358 | } | |
| 10730 |
4/4✓ Branch 0 taken 597 times.
✓ Branch 1 taken 942 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 341 times.
|
1539 | else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8))) |
| 10731 | { | ||
| 10732 | 341 | dir=right; | |
| 10733 | 341 | } | |
| 10734 |
4/4✓ Branch 0 taken 568 times.
✓ Branch 1 taken 630 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 312 times.
|
1198 | else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8))) |
| 10735 | { | ||
| 10736 | 312 | dir=r_up; | |
| 10737 | 312 | } | |
| 10738 |
4/4✓ Branch 0 taken 278 times.
✓ Branch 1 taken 608 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 22 times.
|
886 | else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8))) |
| 10739 | { | ||
| 10740 | 22 | dir=up; | |
| 10741 | 22 | } | |
| 10742 |
4/4✓ Branch 0 taken 590 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 334 times.
✓ Branch 3 taken 256 times.
|
864 | else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8))) |
| 10743 | { | ||
| 10744 | 334 | dir=l_up; | |
| 10745 | 334 | } | |
| 10746 | else | ||
| 10747 | { | ||
| 10748 | 530 | dir=left; | |
| 10749 | } | ||
| 10750 | } | ||
| 10751 | 2543 | } | |
| 10752 | |||
| 10753 | 17944 | bool eZora::animate(int32_t index) | |
| 10754 | { | ||
| 10755 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17944 times.
|
17944 | if(switch_hooked) return enemy::animate(index); |
| 10756 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17930 times.
|
17944 | if(dying) |
| 10757 | 14 | return Dead(index); | |
| 10758 | |||
| 10759 |
2/2✓ Branch 0 taken 17793 times.
✓ Branch 1 taken 137 times.
|
17930 | if(clk==0) |
| 10760 | { | ||
| 10761 | 137 | removearmos(x,y,ffcactivated); | |
| 10762 | 137 | } | |
| 10763 | |||
| 10764 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 17927 times.
|
17930 | if(watch) |
| 10765 | { | ||
| 10766 | 3 | ++clock_zoras[id]; | |
| 10767 | 3 | return true; | |
| 10768 | } | ||
| 10769 | |||
| 10770 |
2/2✓ Branch 0 taken 15384 times.
✓ Branch 1 taken 2543 times.
|
17927 | if(get_qr(qr_NEWENEMYTILES)) |
| 10771 | { | ||
| 10772 | 2543 | facehero(); | |
| 10773 | 2543 | } | |
| 10774 | |||
| 10775 |
6/6✓ Branch 0 taken 119 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 17427 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 43 times.
|
17927 | switch(clk) |
| 10776 | { | ||
| 10777 | case 0: // reposition him | ||
| 10778 | { | ||
| 10779 | 143 | int32_t t=0; | |
| 10780 | 143 | int32_t pos2=zc_oldrand()%160 + 16; | |
| 10781 | 143 | bool placed=false; | |
| 10782 | |||
| 10783 |
4/4✓ Branch 0 taken 142 times.
✓ Branch 1 taken 811 times.
✓ Branch 2 taken 532 times.
✓ Branch 3 taken 137 times.
|
953 | while(!placed && t<160) |
| 10784 | { | ||
| 10785 | 532 | int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7)); | |
| 10786 |
5/6✓ Branch 0 taken 147 times.
✓ Branch 1 taken 385 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 136 times.
|
671 | if(watertype && ((editorflags & ENEMY_FLAG6) || |
| 10787 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
|
147 | ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5)) |
| 10788 |
3/4✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✓ Branch 3 taken 139 times.
|
147 | || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15) |
| 10789 | { | ||
| 10790 | 136 | x=(pos2&15)<<4; | |
| 10791 | 136 | y=pos2&0xF0; | |
| 10792 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 134 times.
|
136 | if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked. |
| 10793 | 136 | hxofs=1000; // avoid hit detection | |
| 10794 | 136 | stunclk=0; | |
| 10795 | 136 | placed=true; | |
| 10796 | 136 | } | |
| 10797 | |||
| 10798 | 810 | pos2+=19; | |
| 10799 | |||
| 10800 |
2/2✓ Branch 0 taken 705 times.
✓ Branch 1 taken 105 times.
|
810 | if(pos2>=176) |
| 10801 | 105 | pos2-=160; | |
| 10802 | |||
| 10803 | 810 | ++t; | |
| 10804 | } | ||
| 10805 | |||
| 10806 |
3/4✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
|
137 | if(!placed || whistleclk>=88) // can't place him, he's gone |
| 10807 | 1 | return true; | |
| 10808 | |||
| 10809 | } | ||
| 10810 | 136 | break; | |
| 10811 | |||
| 10812 | case 35: | ||
| 10813 |
2/2✓ Branch 0 taken 19 times.
✓ Branch 1 taken 100 times.
|
119 | if(!get_qr(qr_NEWENEMYTILES)) |
| 10814 | { | ||
| 10815 | 100 | dir=(Hero.y+8<y)?up:down; | |
| 10816 | 100 | } | |
| 10817 | |||
| 10818 | 119 | hxofs=0; | |
| 10819 | 119 | break; | |
| 10820 | |||
| 10821 | case 35+19: | ||
| 10822 | 106 | addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez); | |
| 10823 | 106 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 10824 | 106 | break; | |
| 10825 | |||
| 10826 | case 35+66: | ||
| 10827 | 89 | hxofs=1000; | |
| 10828 | 89 | break; | |
| 10829 | |||
| 10830 | case 198: | ||
| 10831 | 43 | clk=-1; | |
| 10832 | 43 | break; | |
| 10833 | } | ||
| 10834 | |||
| 10835 | 17920 | return enemy::animate(index); | |
| 10836 | 17938 | } | |
| 10837 | |||
| 10838 | 17952 | void eZora::draw(BITMAP *dest) | |
| 10839 | { | ||
| 10840 |
2/2✓ Branch 0 taken 408 times.
✓ Branch 1 taken 17544 times.
|
17952 | if(clk<3) |
| 10841 | 408 | return; | |
| 10842 | |||
| 10843 | 17544 | update_enemy_frame(); | |
| 10844 | 17544 | enemy::draw(dest); | |
| 10845 | 17952 | } | |
| 10846 | |||
| 10847 | ✗ | bool eZora::isSubmerged() const | |
| 10848 | { | ||
| 10849 | ✗ | return ( clk < 3 ); | |
| 10850 | } | ||
| 10851 | |||
| 10852 |
3/6✓ Branch 0 taken 1769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1769 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1769 times.
✗ Branch 5 not taken.
|
3538 | eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) |
| 10853 | 1769 | { | |
| 10854 | 1769 | multishot= timer = fired = dashing = 0; | |
| 10855 | 1769 | hashero = false; | |
| 10856 | 1769 | dummy_bool[0]=false; | |
| 10857 | 1769 | shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0; | |
| 10858 |
5/6✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1758 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 8 times.
|
1769 | if(dmisc9==e9tARMOS && zc_oldrand()&1) |
| 10859 | { | ||
| 10860 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | step=zslongToFix(dmisc10*100); |
| 10861 | |||
| 10862 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | if(anim==aARMOS4) o_tile+=20; |
| 10863 | 3 | } | |
| 10864 | |||
| 10865 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1758 times.
|
1769 | if(flags & guy_fadeflicker) |
| 10866 | { | ||
| 10867 | 11 | clk=0; | |
| 10868 | 11 | superman = 1; | |
| 10869 | 11 | fading=fade_flicker; | |
| 10870 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; |
| 10871 | 11 | dir=down; | |
| 10872 | |||
| 10873 |
4/6✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 8 times.
|
11 | if(!canmove(down,(zfix)8,spw_none,false)) |
| 10874 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | clk3=int32_t(13.0/step); |
| 10875 | 11 | } | |
| 10876 |
1/2✓ Branch 0 taken 1758 times.
✗ Branch 1 not taken.
|
1758 | else if(flags & guy_fadeinstant) |
| 10877 | { | ||
| 10878 | ✗ | clk=0; | |
| 10879 | ✗ | } | |
| 10880 | |||
| 10881 |
1/2✓ Branch 0 taken 1769 times.
✗ Branch 1 not taken.
|
1769 | shadowdistance = 0; |
| 10882 | 1769 | clk4 = clk5 = 0; | |
| 10883 | //nets+2380; | ||
| 10884 | 1769 | SIZEflags = d->SIZEflags; | |
| 10885 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1769 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1769 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 10886 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 10887 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 10888 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1769 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1769 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 10889 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1769 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1769 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 10890 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1769 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1769 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 10891 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1769 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1769 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 10892 |
1/2✓ Branch 0 taken 1769 times.
✗ Branch 1 not taken.
|
1769 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 10893 |
1/2✓ Branch 0 taken 1769 times.
✗ Branch 1 not taken.
|
1769 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 10894 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 10895 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1769 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1769 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 10896 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1769 times.
|
1769 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 10897 | { | ||
| 10898 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 10899 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 10900 | ✗ | } | |
| 10901 | |||
| 10902 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1769 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1769 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; |
| 10903 | 1769 | } | |
| 10904 | |||
| 10905 | 436717 | bool eStalfos::animate(int32_t index) | |
| 10906 | { | ||
| 10907 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 436717 times.
|
436717 | if(switch_hooked) return enemy::animate(index); |
| 10908 |
3/4✓ Branch 0 taken 436575 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 436575 times.
|
436717 | if(fallclk||drownclk) |
| 10909 | { | ||
| 10910 | 142 | return enemy::animate(index); | |
| 10911 | } | ||
| 10912 |
2/2✓ Branch 0 taken 14153 times.
✓ Branch 1 taken 422422 times.
|
436575 | if(dying) |
| 10913 | { | ||
| 10914 |
1/2✓ Branch 0 taken 14153 times.
✗ Branch 1 not taken.
|
14153 | if(hashero) |
| 10915 | { | ||
| 10916 | ✗ | Hero.setEaten(0); | |
| 10917 | ✗ | hashero=false; | |
| 10918 | ✗ | } | |
| 10919 | |||
| 10920 |
5/14✓ Branch 0 taken 656 times.
✓ Branch 1 taken 13497 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 640 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
14153 | if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons) |
| 10921 | { | ||
| 10922 | ✗ | hp=-1000; | |
| 10923 | ✗ | weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false); | |
| 10924 | ✗ | Ewpns.add(ew); | |
| 10925 | ✗ | ew->fakez = fakez; | |
| 10926 | |||
| 10927 | ✗ | if(wpn==ewSBomb || wpn==ewBomb) | |
| 10928 | { | ||
| 10929 | ✗ | ew->step=0; | |
| 10930 | ✗ | ew->id=wpn; | |
| 10931 | ✗ | ew->misc=50; | |
| 10932 | ✗ | ew->clk=48; | |
| 10933 | ✗ | } | |
| 10934 | |||
| 10935 | ✗ | fired=true; | |
| 10936 | ✗ | } | |
| 10937 |
5/6✓ Branch 0 taken 7630 times.
✓ Branch 1 taken 6523 times.
✓ Branch 2 taken 6460 times.
✓ Branch 3 taken 1170 times.
✓ Branch 4 taken 6460 times.
✗ Branch 5 not taken.
|
14153 | else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo |
| 10938 | { | ||
| 10939 | ✗ | if(!dummy_bool[0]) | |
| 10940 | { | ||
| 10941 | ✗ | int32_t wpn2 = wpn+dmisc3; | |
| 10942 | |||
| 10943 | ✗ | if(wpn2 <= wEnemyWeapons || wpn2 >= wMax) | |
| 10944 | { | ||
| 10945 | ✗ | wpn2=wpn; | |
| 10946 | ✗ | } | |
| 10947 | |||
| 10948 | ✗ | dummy_bool[0]=true; | |
| 10949 | ✗ | addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez); | |
| 10950 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 10951 | ✗ | addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez); | |
| 10952 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 10953 | ✗ | addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez); | |
| 10954 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 10955 | ✗ | addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez); | |
| 10956 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 10957 | ✗ | addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez); | |
| 10958 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 10959 | ✗ | addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez); | |
| 10960 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 10961 | ✗ | addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez); | |
| 10962 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 10963 | ✗ | addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez); | |
| 10964 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 10965 | ✗ | sfx(wpnsfx(wpn2),pan(int32_t(x))); | |
| 10966 | ✗ | } | |
| 10967 | ✗ | } | |
| 10968 | |||
| 10969 | 14153 | KillWeapon(); | |
| 10970 | 14153 | return Dead(index); | |
| 10971 | } | ||
| 10972 | //vire split | ||
| 10973 | //2.10 checked !fslide(), but nothing uses that now anyway. -Z | ||
| 10974 | //Perhaps the problem occurs when vires die because they have < 0 HP, in this check? | ||
| 10975 |
13/14✓ Branch 0 taken 780 times.
✓ Branch 1 taken 421642 times.
✓ Branch 2 taken 780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 766 times.
✓ Branch 6 taken 27559 times.
✓ Branch 7 taken 394849 times.
✓ Branch 8 taken 27489 times.
✓ Branch 9 taken 70 times.
✓ Branch 10 taken 210 times.
✓ Branch 11 taken 27279 times.
✓ Branch 12 taken 38 times.
✓ Branch 13 taken 172 times.
|
422422 | else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies |
| 10976 | { | ||
| 10977 | 52 | stop_bgsfx(index); | |
| 10978 | 52 | int32_t kids = guys.Count(); | |
| 10979 | 52 | int32_t id2=dmisc3; | |
| 10980 |
2/2✓ Branch 0 taken 90 times.
✓ Branch 1 taken 52 times.
|
142 | for(int32_t i=0; i < dmisc4; i++) |
| 10981 | { | ||
| 10982 | // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4))) | ||
| 10983 |
4/6✓ Branch 0 taken 68 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
|
90 | if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4))) |
| 10984 | 90 | ((enemy*)guys.spr(kids+i))->count_enemy = false; | |
| 10985 | 90 | } | |
| 10986 | |||
| 10987 |
1/2✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
|
52 | if(itemguy) // Hand down the carried item |
| 10988 | { | ||
| 10989 | ✗ | guycarryingitem = guys.Count()-1; | |
| 10990 | ✗ | ((enemy*)guys.spr(guycarryingitem))->itemguy = true; | |
| 10991 | ✗ | itemguy = false; | |
| 10992 | ✗ | } | |
| 10993 | |||
| 10994 |
1/2✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
|
52 | if(hashero) |
| 10995 | { | ||
| 10996 | ✗ | Hero.setEaten(0); | |
| 10997 | ✗ | hashero=false; | |
| 10998 | ✗ | } | |
| 10999 | |||
| 11000 |
3/4✓ Branch 0 taken 38 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
|
52 | if(deadsfx > 0 && dmisc2==e2tSPLIT) |
| 11001 | ✗ | sfx(deadsfx,pan(int32_t(x))); | |
| 11002 | |||
| 11003 | 52 | return true; | |
| 11004 | } | ||
| 11005 | /* | ||
| 11006 | else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z | ||
| 11007 | { | ||
| 11008 | stop_bgsfx(index); | ||
| 11009 | int32_t kids = guys.Count(); | ||
| 11010 | int32_t id2=dmisc3; | ||
| 11011 | |||
| 11012 | for(int32_t i=0; i < dmisc4; i++) | ||
| 11013 | { | ||
| 11014 | // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4))) | ||
| 11015 | if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4))) | ||
| 11016 | ((enemy*)guys.spr(kids+i))->count_enemy = false; | ||
| 11017 | } | ||
| 11018 | |||
| 11019 | if(itemguy) // Hand down the carried item | ||
| 11020 | { | ||
| 11021 | guycarryingitem = guys.Count()-1; | ||
| 11022 | ((enemy*)guys.spr(guycarryingitem))->itemguy = true; | ||
| 11023 | itemguy = false; | ||
| 11024 | } | ||
| 11025 | |||
| 11026 | if(hashero) | ||
| 11027 | { | ||
| 11028 | Hero.setEaten(0); | ||
| 11029 | hashero=false; | ||
| 11030 | } | ||
| 11031 | |||
| 11032 | return true; | ||
| 11033 | } | ||
| 11034 | */ | ||
| 11035 |
2/2✓ Branch 0 taken 677 times.
✓ Branch 1 taken 421693 times.
|
422370 | if(fading) |
| 11036 | { | ||
| 11037 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 668 times.
|
677 | if(++clk4 > 60) |
| 11038 | { | ||
| 11039 | 9 | clk4=0; | |
| 11040 | 9 | superman=0; | |
| 11041 | 9 | fading=0; | |
| 11042 | |||
| 11043 |
3/6✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
|
9 | if(flags2&cmbflag_armos && z==0 && fakez == 0) |
| 11044 | { | ||
| 11045 | //if a custom size (not 16px by 16px) | ||
| 11046 | |||
| 11047 | //if a custom size (not 16px by 16px) | ||
| 11048 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if (ffcactivated) |
| 11049 | ✗ | removearmosffc(ffcactivated-1); | |
| 11050 | else | ||
| 11051 | { | ||
| 11052 |
4/8✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
|
9 | if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size |
| 11053 | { | ||
| 11054 | //zprint("spawn big enemy from armos\n"); | ||
| 11055 | //if removing a block, then adjust y by -1 as the enemy spawns at y+1 | ||
| 11056 | ✗ | for(int32_t dx = 0; dx < tysz; dx ++) | |
| 11057 | { | ||
| 11058 | ✗ | for(int32_t dy = 0; dy < tysz; dy++) | |
| 11059 | { | ||
| 11060 | ✗ | removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1); | |
| 11061 | ✗ | did_armos = false; | |
| 11062 | ✗ | } | |
| 11063 | ✗ | removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1); | |
| 11064 | ✗ | did_armos = false; | |
| 11065 | ✗ | } | |
| 11066 | ✗ | for(int32_t dy = 0; dy < tysz; dy ++) | |
| 11067 | { | ||
| 11068 | ✗ | removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1); | |
| 11069 | ✗ | did_armos = false; | |
| 11070 | ✗ | } | |
| 11071 | ✗ | removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1); | |
| 11072 | ✗ | } | |
| 11073 | 9 | else removearmos(x,y); | |
| 11074 | } | ||
| 11075 | /* | ||
| 11076 | if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size | ||
| 11077 | { | ||
| 11078 | //if removing a block, then adjust y by -1 as the enemy spawns at y+1 | ||
| 11079 | for(int32_t dx = 0; dx < hxsz; dx += 16) | ||
| 11080 | { | ||
| 11081 | for(int32_t dy = 0; dy < hysz; dy += 16) | ||
| 11082 | { | ||
| 11083 | removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated); | ||
| 11084 | did_armos = false; | ||
| 11085 | } | ||
| 11086 | removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated); | ||
| 11087 | did_armos = false; | ||
| 11088 | } | ||
| 11089 | for(int32_t dy = 0; dy < hysz; dy += 16) | ||
| 11090 | { | ||
| 11091 | removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated); | ||
| 11092 | did_armos = false; | ||
| 11093 | } | ||
| 11094 | removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated); | ||
| 11095 | } | ||
| 11096 | else removearmos(x,y,ffcactivated); | ||
| 11097 | */ | ||
| 11098 | |||
| 11099 | 9 | } | |
| 11100 | |||
| 11101 | 9 | clk2=0; | |
| 11102 | |||
| 11103 | 9 | newdir(); | |
| 11104 | 9 | } | |
| 11105 | 668 | else return enemy::animate(index); | |
| 11106 | 9 | } | |
| 11107 |
6/8✓ Branch 0 taken 4968 times.
✓ Branch 1 taken 416725 times.
✓ Branch 2 taken 4968 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4968 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4654 times.
✓ Branch 7 taken 314 times.
|
421693 | else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0) |
| 11108 | 314 | removearmos(x,y,ffcactivated); | |
| 11109 | |||
| 11110 | |||
| 11111 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 421702 times.
|
421702 | if(hashero) |
| 11112 | { | ||
| 11113 | ✗ | Hero.setX(x); | |
| 11114 | ✗ | Hero.setY(y); | |
| 11115 | ✗ | ++clk2; | |
| 11116 | |||
| 11117 | ✗ | if(clk2==(dmisc8==0 ? 95 : dmisc8)) | |
| 11118 | { | ||
| 11119 | ✗ | switch(dmisc7) | |
| 11120 | { | ||
| 11121 | case e7tEATITEMS: | ||
| 11122 | { | ||
| 11123 | ✗ | for(int32_t i=0; i<MAXITEMS; i++) | |
| 11124 | { | ||
| 11125 | ✗ | if(itemsbuf[i].flags&ITEM_EDIBLE) | |
| 11126 | ✗ | game->set_item(i, false); | |
| 11127 | ✗ | } | |
| 11128 | |||
| 11129 | ✗ | break; | |
| 11130 | } | ||
| 11131 | |||
| 11132 | case e7tEATMAGIC: | ||
| 11133 | ✗ | game->change_dmagic(-1*game->get_magicdrainrate()); | |
| 11134 | ✗ | break; | |
| 11135 | |||
| 11136 | case e7tEATRUPEES: | ||
| 11137 | ✗ | game->change_drupy(-1); | |
| 11138 | ✗ | break; | |
| 11139 | } | ||
| 11140 | |||
| 11141 | ✗ | clk2=0; | |
| 11142 | ✗ | } | |
| 11143 | |||
| 11144 | ✗ | if((clk&0x18)==8) // stop its animation on the middle frame | |
| 11145 | ✗ | --clk; | |
| 11146 | ✗ | } | |
| 11147 |
4/4✓ Branch 0 taken 36177 times.
✓ Branch 1 taken 385525 times.
✓ Branch 2 taken 19745 times.
✓ Branch 3 taken 16432 times.
|
421702 | else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc |
| 11148 | { | ||
| 11149 | // Movement engine | ||
| 11150 |
4/6✓ Branch 0 taken 32729 times.
✓ Branch 1 taken 372541 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 372526 times.
✗ Branch 5 not taken.
|
405270 | if(clk>=0) switch(id>>12) |
| 11151 | { | ||
| 11152 | case 0: // Normal movement | ||
| 11153 | |||
| 11154 | /* | ||
| 11155 | if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever | ||
| 11156 | { | ||
| 11157 | // Overloading clk4 (Tribble clock) here... | ||
| 11158 | step=17/100.0; | ||
| 11159 | if(clk4<32) misc=1; | ||
| 11160 | else if(clk4<48) misc=2; | ||
| 11161 | else if(clk4<300) { misc=3; step = dstep/100.0; } | ||
| 11162 | else if(clk4<316) misc=2; | ||
| 11163 | else if(clk4<412) misc=1; | ||
| 11164 | else if(clk4<540) { misc=0; step=0; } | ||
| 11165 | else clk4=0; | ||
| 11166 | if(clk4==48) clk=0; | ||
| 11167 | hxofs=(misc>=2)?0:1000; | ||
| 11168 | if (dmisc9==e9tLEEVER) | ||
| 11169 | variable_walk(rate, homing, 0); | ||
| 11170 | else | ||
| 11171 | variable_walk_8(rate, homing, 4, 0); | ||
| 11172 | break; | ||
| 11173 | } | ||
| 11174 | */ | ||
| 11175 |
4/4✓ Branch 0 taken 362424 times.
✓ Branch 1 taken 10102 times.
✓ Branch 2 taken 9925 times.
✓ Branch 3 taken 352499 times.
|
372526 | if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire |
| 11176 | { | ||
| 11177 | 20027 | vire_hop(); | |
| 11178 | 20027 | break; | |
| 11179 | } | ||
| 11180 |
2/2✓ Branch 0 taken 11083 times.
✓ Branch 1 taken 341416 times.
|
352499 | else if(dmisc9==e9tROPE) //Rope charge |
| 11181 | { | ||
| 11182 |
7/10✓ Branch 0 taken 11083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1459 times.
✓ Branch 3 taken 9624 times.
✓ Branch 4 taken 1345 times.
✓ Branch 5 taken 114 times.
✓ Branch 6 taken 1345 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1345 times.
|
11083 | if(!fired && dashing && !stunclk && !watch && !frozenclock) |
| 11183 | { | ||
| 11184 |
5/6✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1275 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 69 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1345 | if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu |
| 11185 | { | ||
| 11186 | |||
| 11187 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if ( get_qr(qr_BOMBCHUSUPERBOMB) ) |
| 11188 | { | ||
| 11189 | ✗ | hp=-1000; | |
| 11190 | |||
| 11191 | ✗ | if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax) | |
| 11192 | { | ||
| 11193 | ✗ | weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID()); | |
| 11194 | ✗ | Ewpns.add(ew); | |
| 11195 | ✗ | ew->fakez = fakez; | |
| 11196 | |||
| 11197 | ✗ | if(wpn==ewSBomb || wpn==ewBomb) | |
| 11198 | { | ||
| 11199 | ✗ | ew->step=0; | |
| 11200 | ✗ | ew->id=wpn+dmisc3; | |
| 11201 | ✗ | ew->misc=50; | |
| 11202 | ✗ | ew->clk=48; | |
| 11203 | ✗ | } | |
| 11204 | |||
| 11205 | ✗ | fired=true; | |
| 11206 | ✗ | } | |
| 11207 | else | ||
| 11208 | { | ||
| 11209 | ✗ | weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID()); | |
| 11210 | ✗ | Ewpns.add(ew); | |
| 11211 | ✗ | ew->fakez = fakez; | |
| 11212 | |||
| 11213 | ✗ | if(wpn==ewSBomb || wpn==ewBomb) | |
| 11214 | { | ||
| 11215 | ✗ | ew->step=0; | |
| 11216 | ✗ | ew->id=wpn; | |
| 11217 | ✗ | ew->misc=50; | |
| 11218 | ✗ | ew->clk=48; | |
| 11219 | ✗ | } | |
| 11220 | |||
| 11221 | ✗ | fired=true; | |
| 11222 | } | ||
| 11223 | ✗ | } | |
| 11224 | |||
| 11225 | else | ||
| 11226 | { | ||
| 11227 | 1 | hp=-1000; | |
| 11228 | |||
| 11229 | int32_t wpn2; | ||
| 11230 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax) |
| 11231 | 1 | wpn2=wpn; | |
| 11232 | else | ||
| 11233 | ✗ | wpn2=wpn; | |
| 11234 | |||
| 11235 |
5/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
1 | weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID()); |
| 11236 | 1 | Ewpns.add(ew); | |
| 11237 | 1 | ew->fakez = fakez; | |
| 11238 | |||
| 11239 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | if(wpn2==ewSBomb || wpn2==ewBomb) |
| 11240 | { | ||
| 11241 | 1 | ew->step=0; | |
| 11242 | 1 | ew->id=wpn2; | |
| 11243 | 1 | ew->misc=50; | |
| 11244 | 1 | ew->clk=48; | |
| 11245 | 1 | } | |
| 11246 | |||
| 11247 | 1 | fired=true; | |
| 11248 | } | ||
| 11249 | 1 | } | |
| 11250 | 1345 | } | |
| 11251 | |||
| 11252 | 11083 | charge_attack(); | |
| 11253 | 11083 | break; | |
| 11254 | } | ||
| 11255 | /* | ||
| 11256 | * Boomerang-throwers have a halt count of 1 | ||
| 11257 | * Zols have a halt count of (zc_oldrand()&7)<<4 | ||
| 11258 | * Gels have a halt count of ((zc_oldrand()&7)<<3)+2 | ||
| 11259 | * Everything else has 48 | ||
| 11260 | */ | ||
| 11261 | else | ||
| 11262 | { | ||
| 11263 |
2/2✓ Branch 0 taken 18218 times.
✓ Branch 1 taken 323198 times.
|
341416 | if(wpn==ewBrang) // Goriya |
| 11264 | { | ||
| 11265 | 18218 | halting_walk(rate,homing,0,hrate, 1); | |
| 11266 | 18218 | } | |
| 11267 |
4/4✓ Branch 0 taken 318221 times.
✓ Branch 1 taken 4977 times.
✓ Branch 2 taken 126759 times.
✓ Branch 3 taken 191462 times.
|
323198 | else if(dmisc9==e9tNORMAL && wpn==0) |
| 11268 | { | ||
| 11269 |
2/2✓ Branch 0 taken 15122 times.
✓ Branch 1 taken 176340 times.
|
191462 | if(dmisc2==e2tSPLITHIT) // Zol |
| 11270 | { | ||
| 11271 | 15122 | halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4); | |
| 11272 | 15122 | } | |
| 11273 |
4/4✓ Branch 0 taken 11823 times.
✓ Branch 1 taken 164517 times.
✓ Branch 2 taken 3438 times.
✓ Branch 3 taken 8385 times.
|
176340 | else if(frate<=8 && starting_hp==1) // Gel |
| 11274 | { | ||
| 11275 | 8385 | halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2); | |
| 11276 | 8385 | } | |
| 11277 | else // Other | ||
| 11278 | { | ||
| 11279 | 167955 | halting_walk(rate,homing,0,hrate, 48); | |
| 11280 | } | ||
| 11281 | 191462 | } | |
| 11282 | else // Other | ||
| 11283 | { | ||
| 11284 | 131736 | halting_walk(rate,homing,0,hrate, 48); | |
| 11285 | } | ||
| 11286 | } | ||
| 11287 | |||
| 11288 | //if not in midair, and Hero's swinging sword is nearby, jump. | ||
| 11289 | /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0)) | ||
| 11290 | && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32) | ||
| 11291 | { | ||
| 11292 | facehero(false); | ||
| 11293 | sclk=16+((dir^1)<<8); | ||
| 11294 | fall=-FEATHERJUMP; | ||
| 11295 | sfx(WAV_ZN1JUMP,pan(int32_t(x))); | ||
| 11296 | }*/ | ||
| 11297 | 341416 | break; | |
| 11298 | |||
| 11299 | // Following cases are for just after creation-by-splitting. | ||
| 11300 | case 1: | ||
| 11301 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 4 times.
|
15 | if(misc==1) |
| 11302 | { | ||
| 11303 | 4 | dir=up; | |
| 11304 | 4 | step=8; | |
| 11305 | 4 | } | |
| 11306 | |||
| 11307 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12 times.
|
15 | if(misc<=2) |
| 11308 | { | ||
| 11309 | 12 | move(step); | |
| 11310 | |||
| 11311 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
|
12 | if(!canmove(dir,(zfix)0,0,false)) |
| 11312 | 3 | dir=down; | |
| 11313 | 12 | } | |
| 11314 | |||
| 11315 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
|
15 | if(misc==3) |
| 11316 | { | ||
| 11317 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | if(canmove(right,(zfix)16,0,false)) |
| 11318 | 1 | x+=16; | |
| 11319 | 3 | } | |
| 11320 | |||
| 11321 | 15 | ++misc; | |
| 11322 | 15 | break; | |
| 11323 | |||
| 11324 | case 2: | ||
| 11325 | ✗ | if(misc==1) | |
| 11326 | { | ||
| 11327 | ✗ | dir=down; | |
| 11328 | ✗ | step=8; | |
| 11329 | ✗ | } | |
| 11330 | |||
| 11331 | ✗ | if(misc<=2) | |
| 11332 | { | ||
| 11333 | ✗ | move(step); | |
| 11334 | /* | ||
| 11335 | if(!canmove(dir,(zfix)0,0,false)) | ||
| 11336 | dir=up; | ||
| 11337 | */ | ||
| 11338 | ✗ | } | |
| 11339 | |||
| 11340 | ✗ | if(misc==3) | |
| 11341 | { | ||
| 11342 | ✗ | if(canmove(left,(zfix)16,0,false)) | |
| 11343 | ✗ | x-=16; | |
| 11344 | ✗ | } | |
| 11345 | |||
| 11346 | ✗ | ++misc; | |
| 11347 | ✗ | break; | |
| 11348 | |||
| 11349 | default: | ||
| 11350 | ✗ | if(misc==1) | |
| 11351 | { | ||
| 11352 | ✗ | dir=(zc_oldrand()%4); | |
| 11353 | ✗ | step=8; | |
| 11354 | ✗ | } | |
| 11355 | |||
| 11356 | ✗ | if(misc<=2) | |
| 11357 | { | ||
| 11358 | ✗ | move(step); | |
| 11359 | |||
| 11360 | ✗ | if(!canmove(dir,(zfix)0,0,false)) | |
| 11361 | ✗ | dir=dir^1; | |
| 11362 | ✗ | } | |
| 11363 | |||
| 11364 | ✗ | if(misc==3) | |
| 11365 | { | ||
| 11366 | ✗ | if(dir >= left && canmove(dir,(zfix)16,0,false)) | |
| 11367 | ✗ | x+=(dir==left ? -16 : 16); | |
| 11368 | ✗ | } | |
| 11369 | |||
| 11370 | ✗ | ++misc; | |
| 11371 | ✗ | break; | |
| 11372 | 372541 | } | |
| 11373 | |||
| 11374 |
4/4✓ Branch 0 taken 67 times.
✓ Branch 1 taken 405203 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 3 times.
|
405270 | if(id>>12 && misc>=4) //recently spawned by a split enemy |
| 11375 | { | ||
| 11376 | 3 | id&=0xFFF; | |
| 11377 | 3 | step = zslongToFix(dstep*100); | |
| 11378 | |||
| 11379 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if(x<32) x=32; |
| 11380 | |||
| 11381 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | if(x>208) x=208; |
| 11382 | |||
| 11383 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | if(y<32) y=32; |
| 11384 | |||
| 11385 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if(y>128) y=128; |
| 11386 | |||
| 11387 | 3 | misc=3; | |
| 11388 | 3 | } | |
| 11389 | 405270 | } | |
| 11390 | else | ||
| 11391 | { | ||
| 11392 | //sfx(wpnsfx(wpn),pan(int32_t(x))); | ||
| 11393 |
1/2✓ Branch 0 taken 16432 times.
✗ Branch 1 not taken.
|
16432 | if(clk2>2) clk2--; |
| 11394 | } | ||
| 11395 | |||
| 11396 | // Fire Zol | ||
| 11397 |
7/8✓ Branch 0 taken 183296 times.
✓ Branch 1 taken 238406 times.
✓ Branch 2 taken 1284 times.
✓ Branch 3 taken 182012 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 1268 times.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
|
421702 | if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk) |
| 11398 | { | ||
| 11399 | 16 | addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez); | |
| 11400 | 16 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 11401 | |||
| 11402 | 16 | int32_t i=Ewpns.Count()-1; | |
| 11403 | 16 | weapon *ew = (weapon*)(Ewpns.spr(i)); | |
| 11404 | |||
| 11405 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
16 | if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1) |
| 11406 | { | ||
| 11407 | ✗ | ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames; | |
| 11408 | ✗ | if ( ew->do_animation ) ew->tile+=ew->aframe; | |
| 11409 | ✗ | } | |
| 11410 | 16 | } | |
| 11411 | // Goriya | ||
| 11412 |
14/16✓ Branch 0 taken 36177 times.
✓ Branch 1 taken 385509 times.
✓ Branch 2 taken 17101 times.
✓ Branch 3 taken 19076 times.
✓ Branch 4 taken 16520 times.
✓ Branch 5 taken 581 times.
✓ Branch 6 taken 16155 times.
✓ Branch 7 taken 365 times.
✓ Branch 8 taken 16155 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 16078 times.
✓ Branch 11 taken 77 times.
✓ Branch 12 taken 16078 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 15844 times.
✓ Branch 15 taken 234 times.
|
421686 | else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut()) |
| 11413 | { | ||
| 11414 | 234 | misc=index+100; | |
| 11415 |
7/14✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 234 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 234 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 234 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 234 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 234 times.
✗ Branch 13 not taken.
|
234 | Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false)); |
| 11416 | 234 | ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false; | |
| 11417 | |||
| 11418 |
1/2✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
|
234 | if(dmisc1==2) |
| 11419 | { | ||
| 11420 | ✗ | int32_t ndir=dir; | |
| 11421 | |||
| 11422 | ✗ | if(Hero.x-x==0) | |
| 11423 | { | ||
| 11424 | ✗ | ndir=(Hero.y+8<y)?up:down; | |
| 11425 | ✗ | } | |
| 11426 | else //turn to face Hero | ||
| 11427 | { | ||
| 11428 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 11429 | ✗ | double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); | |
| 11430 | |||
| 11431 | ✗ | if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8))) | |
| 11432 | { | ||
| 11433 | ✗ | ndir=down; | |
| 11434 | ✗ | } | |
| 11435 | ✗ | else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8))) | |
| 11436 | { | ||
| 11437 | ✗ | ndir=right; | |
| 11438 | ✗ | } | |
| 11439 | ✗ | else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8))) | |
| 11440 | { | ||
| 11441 | ✗ | ndir=up; | |
| 11442 | ✗ | } | |
| 11443 | else | ||
| 11444 | { | ||
| 11445 | ✗ | ndir=left; | |
| 11446 | } | ||
| 11447 | } | ||
| 11448 | |||
| 11449 | ✗ | ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true; | |
| 11450 | |||
| 11451 | ✗ | if(canmove(ndir,false)) | |
| 11452 | { | ||
| 11453 | ✗ | dir=ndir; | |
| 11454 | ✗ | } | |
| 11455 | ✗ | } | |
| 11456 | 234 | } | |
| 11457 |
13/16✓ Branch 0 taken 420039 times.
✓ Branch 1 taken 1413 times.
✓ Branch 2 taken 4373 times.
✓ Branch 3 taken 417079 times.
✓ Branch 4 taken 3687 times.
✓ Branch 5 taken 686 times.
✓ Branch 6 taken 3687 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3568 times.
✓ Branch 9 taken 119 times.
✓ Branch 10 taken 3264 times.
✓ Branch 11 taken 304 times.
✓ Branch 12 taken 3264 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 3264 times.
|
421452 | else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch) |
| 11458 |
2/3✓ Branch 0 taken 704 times.
✓ Branch 1 taken 2560 times.
✗ Branch 2 not taken.
|
3264 | switch(dmisc1) |
| 11459 | { | ||
| 11460 | case e1tCONSTANT: //Deathnut | ||
| 11461 | { | ||
| 11462 | // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack... | ||
| 11463 |
2/2✓ Branch 0 taken 2511 times.
✓ Branch 1 taken 49 times.
|
2560 | if(clk5>64) |
| 11464 | { | ||
| 11465 | 49 | clk5=0; | |
| 11466 | 49 | fired=false; | |
| 11467 | 49 | } | |
| 11468 | |||
| 11469 | 2560 | clk5+=(zc_oldrand()&3); | |
| 11470 | |||
| 11471 |
4/4✓ Branch 0 taken 1532 times.
✓ Branch 1 taken 1028 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 1044 times.
|
2560 | if((clk5>24)&&(clk5<52)) |
| 11472 | { | ||
| 11473 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1044 times.
|
1044 | if ( do_animation )tile+=20; //firing |
| 11474 | |||
| 11475 |
4/4✓ Branch 0 taken 594 times.
✓ Branch 1 taken 450 times.
✓ Branch 2 taken 536 times.
✓ Branch 3 taken 58 times.
|
1044 | if(!fired&&(clk5>=38)) |
| 11476 | { | ||
| 11477 |
5/10✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58 times.
✗ Branch 9 not taken.
|
58 | Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false)); |
| 11478 | 58 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 11479 | 58 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 11480 | 58 | fired=true; | |
| 11481 | 58 | } | |
| 11482 | 1044 | } | |
| 11483 | |||
| 11484 | 2560 | break; | |
| 11485 | } | ||
| 11486 | |||
| 11487 | case e1tFIREOCTO: //Fire Octo | ||
| 11488 | ✗ | timer=zc_oldrand()%50+50; | |
| 11489 | ✗ | break; | |
| 11490 | |||
| 11491 | default: | ||
| 11492 | 704 | FireWeapon(); | |
| 11493 | 704 | break; | |
| 11494 | 3264 | } | |
| 11495 | |||
| 11496 | /* Fire again if: | ||
| 11497 | * - clk2 about to run out | ||
| 11498 | * - not already double-firing (dmisc1 is 1) | ||
| 11499 | * - not carrying Hero | ||
| 11500 | * - one in 0xF chance | ||
| 11501 | */ | ||
| 11502 |
8/10✓ Branch 0 taken 18445 times.
✓ Branch 1 taken 403257 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 18403 times.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 37 times.
✓ Branch 9 taken 5 times.
|
421702 | if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15)) |
| 11503 | { | ||
| 11504 | #if 1 | ||
| 11505 | 5 | newdir(rate, homing, grumble); | |
| 11506 | #else | ||
| 11507 | dir^=2; | ||
| 11508 | #endif | ||
| 11509 | 5 | clk2=28; | |
| 11510 | 5 | ++multishot; | |
| 11511 | 5 | } | |
| 11512 | |||
| 11513 |
2/2✓ Branch 0 taken 89935 times.
✓ Branch 1 taken 331767 times.
|
421702 | if(clk2==0) |
| 11514 | { | ||
| 11515 | 331767 | multishot = 0; | |
| 11516 | 331767 | } | |
| 11517 | |||
| 11518 |
1/2✓ Branch 0 taken 421702 times.
✗ Branch 1 not taken.
|
421702 | if(timer) //Fire Octo |
| 11519 | { | ||
| 11520 | ✗ | clk2=15; //this keeps the octo in place until he's done firing | |
| 11521 | |||
| 11522 | ✗ | if(!(timer%4)) | |
| 11523 | { | ||
| 11524 | ✗ | FireBreath(false); | |
| 11525 | ✗ | } | |
| 11526 | |||
| 11527 | ✗ | --timer; | |
| 11528 | ✗ | } | |
| 11529 | |||
| 11530 |
2/2✓ Branch 0 taken 419462 times.
✓ Branch 1 taken 2240 times.
|
421702 | if(dmisc2==e2tTRIBBLE) |
| 11531 | 2240 | ++clk4; | |
| 11532 | |||
| 11533 |
7/10✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 419462 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 421688 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
|
421702 | if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4) |
| 11534 | { | ||
| 11535 | 14 | int32_t kids = guys.Count(); | |
| 11536 | 14 | int32_t id2=dmisc3; | |
| 11537 | |||
| 11538 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
|
28 | for(int32_t i=0; i<dmisc4; i++) |
| 11539 | { | ||
| 11540 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if(addenemy(x,y,id2,-24)) |
| 11541 | { | ||
| 11542 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if(itemguy) // Hand down the carried item |
| 11543 | { | ||
| 11544 | ✗ | guycarryingitem = guys.Count()-1; | |
| 11545 | ✗ | ((enemy*)guys.spr(guycarryingitem))->itemguy = true; | |
| 11546 | ✗ | itemguy = false; | |
| 11547 | ✗ | } | |
| 11548 | |||
| 11549 | 14 | ((enemy*)guys.spr(kids+i))->count_enemy = false; | |
| 11550 | 14 | } | |
| 11551 | 14 | } | |
| 11552 | |||
| 11553 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if(hashero) |
| 11554 | { | ||
| 11555 | ✗ | Hero.setEaten(0); | |
| 11556 | ✗ | hashero=false; | |
| 11557 | ✗ | } | |
| 11558 | |||
| 11559 | 14 | stop_bgsfx(index); | |
| 11560 | 14 | return true; | |
| 11561 | } | ||
| 11562 | |||
| 11563 | 421688 | return enemy::animate(index); | |
| 11564 | 436717 | } | |
| 11565 | |||
| 11566 | 437284 | void eStalfos::draw(BITMAP *dest) | |
| 11567 | { | ||
| 11568 | /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged | ||
| 11569 | { | ||
| 11570 | clk4--; //Kludge | ||
| 11571 | return; | ||
| 11572 | }*/ | ||
| 11573 | |||
| 11574 | /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1) | ||
| 11575 | { | ||
| 11576 | cs = dcset; | ||
| 11577 | }*/ | ||
| 11578 | 437284 | update_enemy_frame(); | |
| 11579 | |||
| 11580 |
7/8✓ Branch 0 taken 437142 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 437142 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 436825 times.
✓ Branch 6 taken 231 times.
✓ Branch 7 taken 86 times.
|
437284 | if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing) |
| 11581 | { | ||
| 11582 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | if ( do_animation )tile+=20; |
| 11583 | 86 | } | |
| 11584 | |||
| 11585 | 437284 | enemy::draw(dest); | |
| 11586 | 437284 | } | |
| 11587 | |||
| 11588 | 115964 | void eStalfos::drawshadow(BITMAP *dest, bool translucent) | |
| 11589 | { | ||
| 11590 | 115964 | int32_t tempy=yofs; | |
| 11591 | |||
| 11592 | /* | ||
| 11593 | if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) { | ||
| 11594 | flip = 0; | ||
| 11595 | int32_t f2=get_qr(qr_NEWENEMYTILES)? | ||
| 11596 | (clk/(frate/4)):((clk>=(frate>>1))?1:0); | ||
| 11597 | shadowtile = wpnsbuf[spr_shadow].tile+f2; | ||
| 11598 | yofs+=(((int32_t)y+17)&0xF0)-y; | ||
| 11599 | yofs+=8; | ||
| 11600 | } | ||
| 11601 | */ | ||
| 11602 |
4/4✓ Branch 0 taken 113919 times.
✓ Branch 1 taken 2045 times.
✓ Branch 2 taken 111313 times.
✓ Branch 3 taken 4651 times.
|
115964 | if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS)) |
| 11603 | { | ||
| 11604 | 4651 | flip = 0; | |
| 11605 | 4651 | int32_t fdiv = frate/4; | |
| 11606 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4651 times.
|
4651 | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; |
| 11607 | |||
| 11608 |
1/2✓ Branch 0 taken 4651 times.
✗ Branch 1 not taken.
|
4651 | int32_t f2=get_qr(qr_NEWENEMYTILES)? |
| 11609 | 4651 | efrate:((clk>=(frate>>1))?1:0); | |
| 11610 | 4651 | shadowtile = wpnsbuf[spr_shadow].tile; | |
| 11611 | |||
| 11612 |
1/2✓ Branch 0 taken 4651 times.
✗ Branch 1 not taken.
|
4651 | if(get_qr(qr_NEWENEMYTILES)) |
| 11613 | { | ||
| 11614 | 4651 | shadowtile+=f2; | |
| 11615 | 4651 | } | |
| 11616 | else | ||
| 11617 | { | ||
| 11618 | ✗ | shadowtile+=f2?1:0; | |
| 11619 | } | ||
| 11620 | |||
| 11621 | 4651 | yofs+=shadowdistance; | |
| 11622 | 4651 | yofs+=8; | |
| 11623 | 4651 | } | |
| 11624 |
3/4✓ Branch 0 taken 113919 times.
✓ Branch 1 taken 2045 times.
✓ Branch 2 taken 115964 times.
✗ Branch 3 not taken.
|
115964 | if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW)) |
| 11625 | { | ||
| 11626 | ✗ | flip = 0; | |
| 11627 | ✗ | int32_t fdiv = frate/4; | |
| 11628 | ✗ | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; | |
| 11629 | |||
| 11630 | ✗ | int32_t f2=get_qr(qr_NEWENEMYTILES)? | |
| 11631 | ✗ | efrate:((clk>=(frate>>1))?1:0); | |
| 11632 | ✗ | shadowtile = wpnsbuf[spr_shadow].tile; | |
| 11633 | |||
| 11634 | ✗ | if(get_qr(qr_NEWENEMYTILES)) | |
| 11635 | { | ||
| 11636 | ✗ | shadowtile+=f2; | |
| 11637 | ✗ | } | |
| 11638 | else | ||
| 11639 | { | ||
| 11640 | ✗ | shadowtile+=f2?1:0; | |
| 11641 | } | ||
| 11642 | ✗ | } | |
| 11643 |
2/2✓ Branch 0 taken 515 times.
✓ Branch 1 taken 115449 times.
|
115964 | if(!shadow_overpit(this)) |
| 11644 | 115449 | enemy::drawshadow(dest, translucent); | |
| 11645 | 115964 | yofs=tempy; | |
| 11646 | 115964 | } | |
| 11647 | |||
| 11648 | 2933 | int32_t eStalfos::takehit(weapon *w, weapon* realweap) | |
| 11649 | { | ||
| 11650 | 2933 | int32_t wpnId = w->id; | |
| 11651 | 2933 | int32_t wpnDir = w->dir; | |
| 11652 | |||
| 11653 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2933 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2933 | if(wpnId==wHammer && shield && (flags & guy_bkshield) |
| 11654 | ✗ | && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up)) | |
| 11655 | ✗ | || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right)))) | |
| 11656 | { | ||
| 11657 | ✗ | shield = false; | |
| 11658 | ✗ | flags &= ~(inv_left|inv_right|inv_back|inv_front); | |
| 11659 | |||
| 11660 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 11661 | ✗ | o_tile=s_tile; | |
| 11662 | ✗ | } | |
| 11663 | |||
| 11664 | 2933 | int32_t ret = enemy::takehit(w,realweap); | |
| 11665 | |||
| 11666 |
4/4✓ Branch 0 taken 741 times.
✓ Branch 1 taken 2192 times.
✓ Branch 2 taken 685 times.
✓ Branch 3 taken 56 times.
|
2933 | if(sclk && dmisc2==e2tSPLITHIT) |
| 11667 | 56 | sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z | |
| 11668 | |||
| 11669 | 2933 | return ret; | |
| 11670 | } | ||
| 11671 | |||
| 11672 | 11083 | void eStalfos::charge_attack() | |
| 11673 | { | ||
| 11674 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11083 times.
|
11083 | if(slide()) |
| 11675 | ✗ | return; | |
| 11676 | |||
| 11677 |
8/12✓ Branch 0 taken 11083 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11083 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10940 times.
✓ Branch 5 taken 143 times.
✓ Branch 6 taken 10317 times.
✓ Branch 7 taken 623 times.
✓ Branch 8 taken 10317 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 10317 times.
|
11083 | if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock ) |
| 11678 | 766 | return; | |
| 11679 | |||
| 11680 |
2/2✓ Branch 0 taken 418 times.
✓ Branch 1 taken 9899 times.
|
10317 | if(clk3<=0) |
| 11681 | { | ||
| 11682 | 418 | fix_coords(true); | |
| 11683 | |||
| 11684 |
2/2✓ Branch 0 taken 105 times.
✓ Branch 1 taken 313 times.
|
418 | if(!dashing) |
| 11685 | { | ||
| 11686 | 313 | int32_t ldir = lined_up(7,false); | |
| 11687 | |||
| 11688 |
4/4✓ Branch 0 taken 33 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 3 times.
|
313 | if(ldir!=-1 && canmove(ldir,false)) |
| 11689 | { | ||
| 11690 | 30 | dir=ldir; | |
| 11691 | 30 | dashing=true; | |
| 11692 | 30 | step=zslongToFix(dstep*100)+1; | |
| 11693 | 30 | } | |
| 11694 | 283 | else newdir(4,0,0); | |
| 11695 | 313 | } | |
| 11696 | |||
| 11697 |
2/2✓ Branch 0 taken 407 times.
✓ Branch 1 taken 11 times.
|
418 | if(!canmove(dir,false)) |
| 11698 | { | ||
| 11699 | 11 | step=zslongToFix(dstep*100); | |
| 11700 | 11 | newdir(); | |
| 11701 | 11 | dashing=false; | |
| 11702 | 11 | } | |
| 11703 | |||
| 11704 | 418 | zfix div = step; | |
| 11705 | |||
| 11706 |
1/2✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
|
418 | if(div == 0) |
| 11707 | ✗ | div = 1; | |
| 11708 | |||
| 11709 | 418 | clk3=(int32_t)(16.0/div); | |
| 11710 | 418 | return; | |
| 11711 | } | ||
| 11712 | |||
| 11713 | 9899 | move(step); | |
| 11714 | 9899 | --clk3; | |
| 11715 | 11083 | } | |
| 11716 | |||
| 11717 | 20027 | void eStalfos::vire_hop() | |
| 11718 | { | ||
| 11719 | //if ( sclk > 0 ) return; //Don't hop during knockback. | ||
| 11720 | |||
| 11721 | // if(dmisc9!=e9tPOLSVOICE) | ||
| 11722 | // { | ||
| 11723 | // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z | ||
| 11724 | // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z | ||
| 11725 | // return; //the enemy should split if it is sliding! | ||
| 11726 | // //else sclk=0; //might need this here, too. -Z | ||
| 11727 | // } | ||
| 11728 |
2/2✓ Branch 0 taken 10102 times.
✓ Branch 1 taken 9925 times.
|
20027 | if(dmisc9!=e9tPOLSVOICE) |
| 11729 | { | ||
| 11730 |
2/2✓ Branch 0 taken 9940 times.
✓ Branch 1 taken 162 times.
|
10102 | if(sclk!=0) |
| 11731 | { | ||
| 11732 |
1/2✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
|
162 | if (dmisc2==e2tSPLITHIT) return; |
| 11733 | //return; | ||
| 11734 | ✗ | } | |
| 11735 | 9940 | } | |
| 11736 | 9925 | else sclk=0; | |
| 11737 | |||
| 11738 |
8/12✓ Branch 0 taken 19865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19611 times.
✓ Branch 5 taken 254 times.
✓ Branch 6 taken 18785 times.
✓ Branch 7 taken 826 times.
✓ Branch 8 taken 18785 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 18785 times.
|
19865 | if(clk<0 || dying || stunclk || watch || ceiling || frozenclock) |
| 11739 | 1080 | return; | |
| 11740 | |||
| 11741 | 18785 | int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1; | |
| 11742 | 18785 | int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16; | |
| 11743 | |||
| 11744 | 18785 | y=floor_y; | |
| 11745 | |||
| 11746 |
2/2✓ Branch 0 taken 18127 times.
✓ Branch 1 taken 658 times.
|
18785 | if(clk3<=0) |
| 11747 | { | ||
| 11748 | 658 | fix_coords(); | |
| 11749 | |||
| 11750 | //z=0; | ||
| 11751 | //if we're not in the middle of a jump or if we can't complete the current jump in the current direction | ||
| 11752 | //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform())) | ||
| 11753 |
5/10✓ Branch 0 taken 106 times.
✓ Branch 1 taken 552 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 93 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
658 | if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests |
| 11754 | 565 | newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none); | |
| 11755 | |||
| 11756 |
2/2✓ Branch 0 taken 106 times.
✓ Branch 1 taken 552 times.
|
658 | if(clk2<=0) |
| 11757 | { | ||
| 11758 | //z=0; | ||
| 11759 |
6/6✓ Branch 0 taken 512 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 503 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 395 times.
✓ Branch 5 taken 108 times.
|
552 | if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate) |
| 11760 | { | ||
| 11761 | |||
| 11762 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 444 times.
|
444 | clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat())); |
| 11763 | /*if (dmisc9==e9tPOLSVOICE ) | ||
| 11764 | { | ||
| 11765 | zprint2("polsvoice jump_width is: %d\n", jump_width); | ||
| 11766 | zprint2("polsvoice raw step is: %d\n", step); | ||
| 11767 | zprint2("polsvoice step.getInt() is: %d\n", step.getInt()); | ||
| 11768 | zprint2("setting clk2 on polsvoice to: %d\n", clk2); | ||
| 11769 | } | ||
| 11770 | else | ||
| 11771 | { | ||
| 11772 | zprint2("vire jump_width is: %d\n", jump_width); | ||
| 11773 | zprint2("vire raw step is: %d\n", step); | ||
| 11774 | zprint2("vire step.getInt() is: %d\n", step.getInt()); | ||
| 11775 | zprint2("setting clk2 on vire to: %d\n", clk2); | ||
| 11776 | } | ||
| 11777 | */ | ||
| 11778 | 444 | } | |
| 11779 | 552 | } | |
| 11780 | |||
| 11781 |
4/4✓ Branch 0 taken 330 times.
✓ Branch 1 taken 328 times.
✓ Branch 2 taken 141 times.
✓ Branch 3 taken 189 times.
|
658 | if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right |
| 11782 | { | ||
| 11783 | 189 | clk2=int32_t((16.0*jump_width)/step.getFloat()); | |
| 11784 | 189 | } | |
| 11785 | |||
| 11786 | 658 | clk3=int32_t(16.0/step.getFloat()); | |
| 11787 | 658 | } | |
| 11788 | |||
| 11789 | 18785 | --clk3; | |
| 11790 | |||
| 11791 |
3/4✓ Branch 0 taken 9686 times.
✓ Branch 1 taken 9099 times.
✓ Branch 2 taken 9686 times.
✗ Branch 3 not taken.
|
18785 | if(dmisc9==e9tPOLSVOICE || clk2>0) |
| 11792 | 18785 | move(step); | |
| 11793 | |||
| 11794 | 18785 | floor_y=y; | |
| 11795 | 18785 | clk2--; | |
| 11796 | |||
| 11797 | //if we're in the middle of a jump | ||
| 11798 |
6/6✓ Branch 0 taken 15327 times.
✓ Branch 1 taken 3458 times.
✓ Branch 2 taken 6512 times.
✓ Branch 3 taken 8815 times.
✓ Branch 4 taken 2482 times.
✓ Branch 5 taken 4030 times.
|
18785 | if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE)) |
| 11799 | { | ||
| 11800 | 11297 | int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height); | |
| 11801 | |||
| 11802 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11297 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11297 | if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity())) |
| 11803 | { | ||
| 11804 | ✗ | if (moveflags & FLAG_USE_FAKE_Z) fakez=h; | |
| 11805 | ✗ | else z=h; | |
| 11806 | ✗ | } | |
| 11807 | else | ||
| 11808 | { | ||
| 11809 | //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height); | ||
| 11810 | //y-=h; | ||
| 11811 | 11297 | y=floor_y-h; | |
| 11812 | 11297 | shadowdistance=h; | |
| 11813 | } | ||
| 11814 | 11297 | } | |
| 11815 | else | ||
| 11816 | 7488 | shadowdistance = 0; | |
| 11817 | 20027 | } | |
| 11818 | |||
| 11819 | ✗ | void eStalfos::eathero() | |
| 11820 | { | ||
| 11821 | ✗ | if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming) | |
| 11822 | { | ||
| 11823 | ✗ | hashero=true; | |
| 11824 | ✗ | y=floor_y; | |
| 11825 | ✗ | z=0; | |
| 11826 | |||
| 11827 | ✗ | if(Hero.isSwimming()) | |
| 11828 | { | ||
| 11829 | ✗ | Hero.setX(x); | |
| 11830 | ✗ | Hero.setY(y); | |
| 11831 | ✗ | } | |
| 11832 | else | ||
| 11833 | { | ||
| 11834 | ✗ | x=Hero.getX(); | |
| 11835 | ✗ | y=Hero.getY(); | |
| 11836 | } | ||
| 11837 | |||
| 11838 | ✗ | clk2=0; | |
| 11839 | ✗ | } | |
| 11840 | ✗ | } | |
| 11841 | |||
| 11842 | 52255 | bool eStalfos::WeaponOut() | |
| 11843 | { | ||
| 11844 |
2/2✓ Branch 0 taken 86733 times.
✓ Branch 1 taken 19979 times.
|
106712 | for(int32_t i=0; i<Ewpns.Count(); i++) |
| 11845 | { | ||
| 11846 |
3/4✓ Branch 0 taken 32276 times.
✓ Branch 1 taken 54457 times.
✓ Branch 2 taken 32276 times.
✗ Branch 3 not taken.
|
86733 | if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang) |
| 11847 | { | ||
| 11848 | 32276 | return true; | |
| 11849 | } | ||
| 11850 | |||
| 11851 | /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self | ||
| 11852 | stop_sfx(bgsfx); | ||
| 11853 | */ | ||
| 11854 | 54457 | } | |
| 11855 | |||
| 11856 | 19979 | return false; | |
| 11857 | 52255 | } | |
| 11858 | |||
| 11859 | 14153 | void eStalfos::KillWeapon() | |
| 11860 | { | ||
| 11861 |
2/2✓ Branch 0 taken 14153 times.
✓ Branch 1 taken 7263 times.
|
21416 | for(int32_t i=0; i<Ewpns.Count(); i++) |
| 11862 | { | ||
| 11863 |
4/4✓ Branch 0 taken 5861 times.
✓ Branch 1 taken 1402 times.
✓ Branch 2 taken 5813 times.
✓ Branch 3 taken 48 times.
|
7263 | if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang) |
| 11864 | { | ||
| 11865 | //only kill this Goriya's boomerang -DD | ||
| 11866 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 30 times.
|
48 | if(((weapon *)Ewpns.spr(i))->parentid == getUID()) |
| 11867 | { | ||
| 11868 | 30 | Ewpns.del(i); | |
| 11869 | 30 | } | |
| 11870 | 48 | } | |
| 11871 | 7263 | } | |
| 11872 | |||
| 11873 |
4/4✓ Branch 0 taken 1170 times.
✓ Branch 1 taken 12983 times.
✓ Branch 2 taken 416 times.
✓ Branch 3 taken 754 times.
|
14153 | if(wpn==ewBrang && !Ewpns.idCount(ewBrang)) |
| 11874 | { | ||
| 11875 | 416 | stop_sfx(WAV_BRANG); | |
| 11876 | 416 | } | |
| 11877 | 14153 | } | |
| 11878 | |||
| 11879 | ✗ | void eStalfos::break_shield() | |
| 11880 | { | ||
| 11881 | ✗ | if(!shield) | |
| 11882 | ✗ | return; | |
| 11883 | |||
| 11884 | ✗ | flags&=~(inv_front | inv_back | inv_left | inv_right); | |
| 11885 | ✗ | shield=false; | |
| 11886 | |||
| 11887 | ✗ | if(get_qr(qr_BRKNSHLDTILES)) | |
| 11888 | ✗ | o_tile=s_tile; | |
| 11889 | ✗ | } | |
| 11890 | |||
| 11891 | 387 | eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 11892 | 387 | { | |
| 11893 |
1/2✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
|
387 | dir=(zc_oldrand()&7)+8; |
| 11894 |
1/2✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
|
387 | step=0; |
| 11895 | 387 | movestatus=1; | |
| 11896 |
3/4✓ Branch 0 taken 379 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 379 times.
|
387 | if (dmisc1 != 1 && dmisc19 > 0) |
| 11897 | { | ||
| 11898 | ✗ | step = dmisc19/100.0; | |
| 11899 | ✗ | movestatus = 1; | |
| 11900 | ✗ | } | |
| 11901 |
1/2✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
|
387 | if (dmisc1 == 2) movestatus=2; |
| 11902 | 387 | c=0; | |
| 11903 | 387 | SIZEflags = d->SIZEflags; | |
| 11904 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
|
387 | if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2; |
| 11905 |
1/2✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
|
387 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 11906 | |||
| 11907 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
|
387 | if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hit_width=12; |
| 11908 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
387 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz; |
| 11909 | |||
| 11910 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
|
387 | if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4; |
| 11911 |
1/2✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
|
387 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 11912 | |||
| 11913 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
|
387 | if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hit_height=8; |
| 11914 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
387 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz; |
| 11915 | |||
| 11916 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
387 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 11917 | //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z | ||
| 11918 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 11919 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
387 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 11920 | |||
| 11921 | |||
| 11922 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
387 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz; |
| 11923 | |||
| 11924 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
387 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; |
| 11925 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
|
387 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 11926 | { | ||
| 11927 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 11928 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 11929 | ✗ | } | |
| 11930 | |||
| 11931 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
387 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; |
| 11932 | 387 | clk4=0; | |
| 11933 | //nets; | ||
| 11934 | 387 | dummy_int[1]=0; | |
| 11935 | 387 | } | |
| 11936 | |||
| 11937 | 74091 | bool eKeese::animate(int32_t index) | |
| 11938 | { | ||
| 11939 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 74091 times.
|
74091 | if(switch_hooked) return enemy::animate(index); |
| 11940 |
2/4✓ Branch 0 taken 74091 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74091 times.
|
74091 | if(fallclk||drownclk) return enemy::animate(index); |
| 11941 |
2/2✓ Branch 0 taken 3553 times.
✓ Branch 1 taken 70538 times.
|
74091 | if(dying) |
| 11942 | 3553 | return Dead(index); | |
| 11943 | |||
| 11944 |
2/2✓ Branch 0 taken 488 times.
✓ Branch 1 taken 70050 times.
|
70538 | if(clk==0) |
| 11945 | { | ||
| 11946 | 488 | removearmos(x,y,ffcactivated); | |
| 11947 | 488 | } | |
| 11948 | |||
| 11949 |
2/2✓ Branch 0 taken 1122 times.
✓ Branch 1 taken 69416 times.
|
70538 | if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat. |
| 11950 | { | ||
| 11951 | 1122 | floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17); | |
| 11952 | 1122 | } | |
| 11953 | else | ||
| 11954 | { | ||
| 11955 |
1/2✓ Branch 0 taken 69416 times.
✗ Branch 1 not taken.
|
69416 | if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17); |
| 11956 | 69416 | else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17); | |
| 11957 | } | ||
| 11958 | |||
| 11959 |
2/2✓ Branch 0 taken 790 times.
✓ Branch 1 taken 69748 times.
|
70538 | if(dmisc2 == e2tKEESETRIB) |
| 11960 | { | ||
| 11961 |
3/4✓ Branch 0 taken 790 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 788 times.
✓ Branch 3 taken 2 times.
|
790 | if(++clk4==(dmisc20>0?dmisc20:256)) |
| 11962 | { | ||
| 11963 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if(!m_walkflag(x,y,0, dir)) |
| 11964 | { | ||
| 11965 | 1 | int32_t kids = guys.Count(); | |
| 11966 | 1 | bool success = false; | |
| 11967 | 1 | int32_t id2=dmisc3; | |
| 11968 | 1 | success = 0 != addenemy((zfix)x,(zfix)y,id2,-24); | |
| 11969 | |||
| 11970 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(success) |
| 11971 | { | ||
| 11972 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(itemguy) // Hand down the carried item |
| 11973 | { | ||
| 11974 | ✗ | guycarryingitem = guys.Count()-1; | |
| 11975 | ✗ | ((enemy*)guys.spr(guycarryingitem))->itemguy = true; | |
| 11976 | ✗ | itemguy = false; | |
| 11977 | ✗ | } | |
| 11978 | |||
| 11979 | 1 | ((enemy*)guys.spr(kids))->count_enemy = count_enemy; | |
| 11980 | 1 | } | |
| 11981 | |||
| 11982 | 1 | stop_bgsfx(index); | |
| 11983 | 1 | return true; | |
| 11984 | } | ||
| 11985 | else | ||
| 11986 | { | ||
| 11987 | 1 | clk4=0; | |
| 11988 | } | ||
| 11989 | 1 | } | |
| 11990 | 789 | } | |
| 11991 | // Keese Tribbles stay on the ground, so there's no problem when they transform. | ||
| 11992 |
3/4✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 68372 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1376 times.
|
69748 | else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity())) |
| 11993 | { | ||
| 11994 |
1/2✓ Branch 0 taken 1376 times.
✗ Branch 1 not taken.
|
1376 | if (get_qr(qr_OLD_KEESE_Z_AXIS)) |
| 11995 | { | ||
| 11996 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1376 times.
|
1376 | if (moveflags & FLAG_USE_FAKE_Z) |
| 11997 | { | ||
| 11998 | ✗ | fakez=int32_t(step/zslongToFix(dstep*100)); | |
| 11999 | // Some variance in keese flight heights when away from Hero | ||
| 12000 | ✗ | fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10)); | |
| 12001 | |||
| 12002 | ✗ | } | |
| 12003 | else | ||
| 12004 | { | ||
| 12005 | 1376 | z=int32_t(step/zslongToFix(dstep*100)); | |
| 12006 | // Some variance in keese flight heights when away from Hero | ||
| 12007 |
2/2✓ Branch 0 taken 1136 times.
✓ Branch 1 taken 240 times.
|
1376 | z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10)); |
| 12008 | } | ||
| 12009 | 1376 | } | |
| 12010 | else | ||
| 12011 | { | ||
| 12012 | ✗ | if (moveflags & FLAG_USE_FAKE_Z) | |
| 12013 | { | ||
| 12014 | ✗ | fakez=int32_t(step/zslongToFix(dstep*100)); | |
| 12015 | // Some variance in keese flight heights when away from Hero | ||
| 12016 | ✗ | fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4)); | |
| 12017 | |||
| 12018 | ✗ | } | |
| 12019 | else | ||
| 12020 | { | ||
| 12021 | ✗ | z=int32_t(step/zslongToFix(dstep*100)); | |
| 12022 | // Some variance in keese flight heights when away from Hero | ||
| 12023 | ✗ | z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4)); | |
| 12024 | } | ||
| 12025 | } | ||
| 12026 | 1376 | } | |
| 12027 | |||
| 12028 | 70537 | return enemy::animate(index); | |
| 12029 | 74091 | } | |
| 12030 | |||
| 12031 | 12104 | void eKeese::drawshadow(BITMAP *dest, bool translucent) | |
| 12032 | { | ||
| 12033 | 12104 | int32_t tempy=yofs; | |
| 12034 | 12104 | flip = 0; | |
| 12035 | 12104 | shadowtile = wpnsbuf[spr_shadow].tile+posframe; | |
| 12036 | |||
| 12037 |
2/2✓ Branch 0 taken 5613 times.
✓ Branch 1 taken 6491 times.
|
12104 | yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8); |
| 12038 |
2/2✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 10679 times.
|
12104 | if(!get_qr(qr_ENEMIESZAXIS)) |
| 12039 | { | ||
| 12040 | 10679 | yofs+=int32_t(step/zslongToFix(dstep*10)); | |
| 12041 | 10679 | } | |
| 12042 | |||
| 12043 |
6/6✓ Branch 0 taken 8751 times.
✓ Branch 1 taken 3353 times.
✓ Branch 2 taken 1425 times.
✓ Branch 3 taken 7326 times.
✓ Branch 4 taken 1413 times.
✓ Branch 5 taken 12 times.
|
12104 | if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0)) |
| 12044 | 8739 | enemy::drawshadow(dest, translucent); | |
| 12045 | 12104 | yofs=tempy; | |
| 12046 | 12104 | } | |
| 12047 | |||
| 12048 | 153277 | void eKeese::draw(BITMAP *dest) | |
| 12049 | { | ||
| 12050 | 153277 | update_enemy_frame(); | |
| 12051 | 153277 | enemy::draw(dest); | |
| 12052 | 153277 | } | |
| 12053 | |||
| 12054 | 187 | void eWizzrobe::submerge(bool set) | |
| 12055 | { | ||
| 12056 |
2/2✓ Branch 0 taken 169 times.
✓ Branch 1 taken 18 times.
|
187 | if(get_qr(qr_OLD_WIZZROBE_SUBMERGING)) |
| 12057 | { | ||
| 12058 | 169 | hxofs = set?1000:0; | |
| 12059 | 169 | return; | |
| 12060 | } | ||
| 12061 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if(submerged == set) return; |
| 12062 | 18 | submerged = set; | |
| 12063 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 8 times.
|
18 | if(set) |
| 12064 | 10 | hxofs+=1000; | |
| 12065 | 8 | else hxofs -= 1000; | |
| 12066 | 187 | } | |
| 12067 | 128 | eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 12068 | 128 | { | |
| 12069 | 128 | hxofs = 0; | |
| 12070 | 128 | submerged = false; | |
| 12071 |
2/2✓ Branch 0 taken 79 times.
✓ Branch 1 taken 49 times.
|
128 | switch(dmisc1) |
| 12072 | { | ||
| 12073 | case 0: | ||
| 12074 | 49 | submerge(true); | |
| 12075 | 49 | fading=fade_invisible; | |
| 12076 | // Set clk to just before the 'reappear' threshold | ||
| 12077 |
6/10✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
|
49 | clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1); |
| 12078 | 49 | break; | |
| 12079 | |||
| 12080 | default: | ||
| 12081 | 79 | dir=(loadside==right)?right:left; | |
| 12082 | 79 | misc=-3; | |
| 12083 | 79 | break; | |
| 12084 | } | ||
| 12085 | |||
| 12086 | //netst+2880; | ||
| 12087 | 128 | charging=false; | |
| 12088 | 128 | firing=false; | |
| 12089 | 128 | fclk=0; | |
| 12090 |
2/2✓ Branch 0 taken 79 times.
✓ Branch 1 taken 49 times.
|
128 | if(!dmisc1) frate=1200+146; //1200 = 20 seconds |
| 12091 | 128 | SIZEflags = d->SIZEflags; | |
| 12092 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
128 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 12093 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 12094 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 12095 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
128 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 12096 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
128 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz; |
| 12097 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
128 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz; |
| 12098 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
128 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz; |
| 12099 |
1/2✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
|
128 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) |
| 12100 | { | ||
| 12101 | ✗ | hxofs = (submerged?hxofs:0)+d->hxofs; | |
| 12102 | ✗ | } | |
| 12103 |
1/2✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
|
128 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 12104 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 12105 |
1/4✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
128 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 12106 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
|
128 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 12107 | { | ||
| 12108 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 12109 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 12110 | ✗ | } | |
| 12111 | |||
| 12112 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
128 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; |
| 12113 | 128 | } | |
| 12114 | |||
| 12115 | 53504 | bool eWizzrobe::animate(int32_t index) | |
| 12116 | { | ||
| 12117 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 53504 times.
|
53504 | if(switch_hooked) return enemy::animate(index); |
| 12118 |
2/4✓ Branch 0 taken 53504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 53504 times.
|
53504 | if(fallclk||drownclk) return enemy::animate(index); |
| 12119 |
2/2✓ Branch 0 taken 918 times.
✓ Branch 1 taken 52586 times.
|
53504 | if(dying) |
| 12120 | { | ||
| 12121 | 918 | return Dead(index); | |
| 12122 | } | ||
| 12123 | |||
| 12124 |
2/2✓ Branch 0 taken 50099 times.
✓ Branch 1 taken 2487 times.
|
52586 | if(clk==0) |
| 12125 | { | ||
| 12126 | 2487 | removearmos(x,y,ffcactivated); | |
| 12127 | 2487 | } | |
| 12128 | |||
| 12129 |
2/2✓ Branch 0 taken 39039 times.
✓ Branch 1 taken 13547 times.
|
52586 | if(dmisc1) // Floating |
| 12130 | { | ||
| 12131 | 39039 | wizzrobe_attack(); | |
| 12132 | 39039 | } | |
| 12133 | else // Teleporting | ||
| 12134 | { | ||
| 12135 |
4/6✓ Branch 0 taken 13547 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1628 times.
✓ Branch 3 taken 11919 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1628 times.
|
13547 | if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk)) |
| 12136 | { | ||
| 12137 | ✗ | fading=0; | |
| 12138 | ✗ | submerge(false); | |
| 12139 | ✗ | solid_update(false); | |
| 12140 | ✗ | } | |
| 12141 |
8/8✓ Branch 0 taken 13097 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 73 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 56 times.
✓ Branch 7 taken 50 times.
|
13547 | else switch(clk) |
| 12142 | { | ||
| 12143 | case 0: | ||
| 12144 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 86 times.
|
88 | if(!dmisc2) |
| 12145 | { | ||
| 12146 | // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos, | ||
| 12147 | // but should not appear on dungeon walls. | ||
| 12148 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller). |
| 12149 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | else if (editorflags&ENEMY_FLAG5) |
| 12150 | { | ||
| 12151 | //2.10 Windrobe | ||
| 12152 | //randomise location and face Hero | ||
| 12153 | ✗ | int32_t t=0; | |
| 12154 | ✗ | bool placed=false; | |
| 12155 | |||
| 12156 | ✗ | while(!placed && t<160) | |
| 12157 | { | ||
| 12158 | ✗ | if(isdungeon()) | |
| 12159 | { | ||
| 12160 | ✗ | x=((zc_oldrand()%12)+2)*16; | |
| 12161 | ✗ | y=((zc_oldrand()%7)+2)*16; | |
| 12162 | ✗ | } | |
| 12163 | else | ||
| 12164 | { | ||
| 12165 | ✗ | x=((zc_oldrand()%14)+1)*16; | |
| 12166 | ✗ | y=((zc_oldrand()%9)+1)*16; | |
| 12167 | } | ||
| 12168 | |||
| 12169 | ✗ | if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32))) | |
| 12170 | { | ||
| 12171 | ✗ | placed=true; | |
| 12172 | ✗ | } | |
| 12173 | |||
| 12174 | ✗ | ++t; | |
| 12175 | } | ||
| 12176 | |||
| 12177 | ✗ | if(abs(x-Hero.getX())<abs(y-Hero.getY())) | |
| 12178 | { | ||
| 12179 | ✗ | if(y<Hero.getY()) | |
| 12180 | { | ||
| 12181 | ✗ | dir=down; | |
| 12182 | ✗ | } | |
| 12183 | else | ||
| 12184 | { | ||
| 12185 | ✗ | dir=up; | |
| 12186 | } | ||
| 12187 | ✗ | } | |
| 12188 | else | ||
| 12189 | { | ||
| 12190 | ✗ | if(x<Hero.getX()) | |
| 12191 | { | ||
| 12192 | ✗ | dir=right; | |
| 12193 | ✗ | } | |
| 12194 | else | ||
| 12195 | { | ||
| 12196 | ✗ | dir=left; | |
| 12197 | } | ||
| 12198 | } | ||
| 12199 | |||
| 12200 | ✗ | if(!placed) // can't place him, he's gone | |
| 12201 | ✗ | return true; | |
| 12202 | |||
| 12203 | |||
| 12204 | //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z | ||
| 12205 | //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct. | ||
| 12206 | ✗ | } | |
| 12207 | 86 | else place_on_axis(true, dmisc4!=0); | |
| 12208 | 86 | } | |
| 12209 | else | ||
| 12210 | { | ||
| 12211 | 2 | int32_t t=0; | |
| 12212 | 2 | bool placed=false; | |
| 12213 | |||
| 12214 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
|
13 | while(!placed && t<160) |
| 12215 | { | ||
| 12216 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
|
11 | if(isdungeon()) |
| 12217 | { | ||
| 12218 | ✗ | x=((zc_oldrand()%12)+2)*16; | |
| 12219 | ✗ | y=((zc_oldrand()%7)+2)*16; | |
| 12220 | ✗ | } | |
| 12221 | else | ||
| 12222 | { | ||
| 12223 | 11 | x=((zc_oldrand()%14)+1)*16; | |
| 12224 | 11 | y=((zc_oldrand()%9)+1)*16; | |
| 12225 | } | ||
| 12226 | |||
| 12227 |
5/6✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 2 times.
|
13 | if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32))) |
| 12228 | { | ||
| 12229 | 2 | placed=true; | |
| 12230 | 2 | } | |
| 12231 | |||
| 12232 | 11 | ++t; | |
| 12233 | } | ||
| 12234 | |||
| 12235 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(abs(x-Hero.getX())<abs(y-Hero.getY())) |
| 12236 | { | ||
| 12237 | ✗ | if(y<Hero.getY()) | |
| 12238 | { | ||
| 12239 | ✗ | dir=down; | |
| 12240 | ✗ | } | |
| 12241 | else | ||
| 12242 | { | ||
| 12243 | ✗ | dir=up; | |
| 12244 | } | ||
| 12245 | ✗ | } | |
| 12246 | else | ||
| 12247 | { | ||
| 12248 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if(x<Hero.getX()) |
| 12249 | { | ||
| 12250 | 1 | dir=right; | |
| 12251 | 1 | } | |
| 12252 | else | ||
| 12253 | { | ||
| 12254 | 1 | dir=left; | |
| 12255 | } | ||
| 12256 | } | ||
| 12257 | |||
| 12258 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!placed) // can't place him, he's gone |
| 12259 | ✗ | return true; | |
| 12260 | } | ||
| 12261 | |||
| 12262 | 88 | fading=fade_flicker; | |
| 12263 | 88 | submerge(false); | |
| 12264 | 88 | solid_update(false); | |
| 12265 | 88 | break; | |
| 12266 | |||
| 12267 | case 64: | ||
| 12268 | 73 | fading=0; | |
| 12269 | 73 | charging=true; | |
| 12270 | 73 | break; | |
| 12271 | |||
| 12272 | case 73: | ||
| 12273 | 65 | charging=false; | |
| 12274 | 65 | firing=40; | |
| 12275 | 65 | break; | |
| 12276 | |||
| 12277 | case 83: | ||
| 12278 | 62 | wizzrobe_attack_for_real(); | |
| 12279 | 62 | break; | |
| 12280 | |||
| 12281 | case 119: | ||
| 12282 | 56 | firing=false; | |
| 12283 | 56 | charging=true; | |
| 12284 | 56 | break; | |
| 12285 | |||
| 12286 | case 128: | ||
| 12287 | 56 | fading=fade_flicker; | |
| 12288 | 56 | charging=false; | |
| 12289 | 56 | break; | |
| 12290 | |||
| 12291 | case 146: | ||
| 12292 | 50 | fading=fade_invisible; | |
| 12293 | 50 | submerge(true); | |
| 12294 | 50 | solid_update(false); | |
| 12295 | |||
| 12296 | [[fallthrough]]; | ||
| 12297 | default: | ||
| 12298 |
3/4✓ Branch 0 taken 13147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13059 times.
✓ Branch 3 taken 88 times.
|
13147 | if(clk>=(146+zc_max(0,dmisc5))) |
| 12299 | 88 | clk=-1; | |
| 12300 | |||
| 12301 | 13147 | break; | |
| 12302 | } | ||
| 12303 | } | ||
| 12304 | |||
| 12305 | 52586 | return enemy::animate(index); | |
| 12306 | 53504 | } | |
| 12307 | |||
| 12308 | 128 | void eWizzrobe::wizzrobe_attack_for_real() | |
| 12309 | { | ||
| 12310 |
1/2✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
|
128 | if(wpn==0) // Edited enemies |
| 12311 | ✗ | return; | |
| 12312 | |||
| 12313 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 121 times.
|
128 | if(dmisc2 == 0) //normal weapon |
| 12314 | { | ||
| 12315 | 121 | addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez); | |
| 12316 | 121 | sfx(WAV_WAND,pan(int32_t(x))); | |
| 12317 | 121 | } | |
| 12318 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
|
7 | else if(dmisc2 == 1) // ring of fire |
| 12319 | { | ||
| 12320 | 6 | addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez); | |
| 12321 | 6 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 12322 | 6 | addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez); | |
| 12323 | 6 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 12324 | 6 | addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez); | |
| 12325 | 6 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 12326 | 6 | addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez); | |
| 12327 | 6 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 12328 | 6 | addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez); | |
| 12329 | 6 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 12330 | 6 | addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez); | |
| 12331 | 6 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 12332 | 6 | addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez); | |
| 12333 | 6 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 12334 | 6 | addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez); | |
| 12335 | 6 | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 12336 | 6 | sfx(WAV_FIRE,pan(int32_t(x))); | |
| 12337 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if (get_qr(qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x))); |
| 12338 | else | ||
| 12339 | { | ||
| 12340 |
1/18✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 6 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
6 | switch(wpn) |
| 12341 | { | ||
| 12342 | ✗ | case ewFireball: sfx(40,pan(int32_t(x))); break; | |
| 12343 | |||
| 12344 | ✗ | case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0? | |
| 12345 | ✗ | case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0? | |
| 12346 | ✗ | case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0? | |
| 12347 | ✗ | case ewRock: sfx(51,pan(int32_t(x))); break; | |
| 12348 | ✗ | case ewMagic: sfx(32,pan(int32_t(x))); break; | |
| 12349 | ✗ | case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0? | |
| 12350 | ✗ | case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0? | |
| 12351 | ✗ | case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0? | |
| 12352 | ✗ | case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0? | |
| 12353 | ✗ | case ewFireTrail: sfx(13,pan(int32_t(x))); break; | |
| 12354 | 6 | case ewFlame: sfx(13,pan(int32_t(x))); break; | |
| 12355 | ✗ | case ewWind: sfx(32,pan(int32_t(x))); break; | |
| 12356 | ✗ | case ewFlame2: sfx(13,pan(int32_t(x))); break; | |
| 12357 | ✗ | case ewFlame2Trail: sfx(13,pan(int32_t(x))); break; | |
| 12358 | ✗ | case ewIce: sfx(44,pan(int32_t(x))); break; | |
| 12359 | ✗ | case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising) | |
| 12360 | ✗ | default: sfx(WAV_FIRE,pan(int32_t(x))); break; | |
| 12361 | |||
| 12362 | } | ||
| 12363 | } | ||
| 12364 | 6 | } | |
| 12365 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | else if(dmisc2==2) // summons specific enemy |
| 12366 | { | ||
| 12367 | 1 | int32_t bc=0; | |
| 12368 | |||
| 12369 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | for(int32_t gc=0; gc<guys.Count(); gc++) |
| 12370 | { | ||
| 12371 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | if((((enemy*)guys.spr(gc))->id) == dmisc3) |
| 12372 | { | ||
| 12373 | 2 | ++bc; | |
| 12374 | 2 | } | |
| 12375 | 3 | } | |
| 12376 | |||
| 12377 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(bc<=40) |
| 12378 | { | ||
| 12379 | 1 | int32_t kids = guys.Count(); | |
| 12380 | 1 | int32_t bats=(zc_oldrand()%3)+1; | |
| 12381 | |||
| 12382 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for(int32_t i=0; i<bats; i++) |
| 12383 | { | ||
| 12384 | // Summon bats (or anything) | ||
| 12385 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(addchild(x,y,dmisc3,-10, this->script_UID)) |
| 12386 | 2 | ((enemy*)guys.spr(kids+i))->count_enemy = false; | |
| 12387 | 2 | } | |
| 12388 | |||
| 12389 | 1 | sfx(WAV_FIRE,pan(int32_t(x))); | |
| 12390 | 1 | } | |
| 12391 | 1 | } | |
| 12392 | ✗ | else if(dmisc2==3) //summon from layer | |
| 12393 | { | ||
| 12394 | ✗ | if(count_layer_enemies()==0) | |
| 12395 | { | ||
| 12396 | ✗ | return; | |
| 12397 | } | ||
| 12398 | |||
| 12399 | ✗ | int32_t kids = guys.Count(); | |
| 12400 | |||
| 12401 | ✗ | if(kids<200) | |
| 12402 | { | ||
| 12403 | ✗ | int32_t newguys=(zc_oldrand()%3)+1; | |
| 12404 | ✗ | bool summoned=false; | |
| 12405 | |||
| 12406 | ✗ | for(int32_t i=0; i<newguys; i++) | |
| 12407 | { | ||
| 12408 | ✗ | int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1); | |
| 12409 | ✗ | int32_t x2=0; | |
| 12410 | ✗ | int32_t y2=0; | |
| 12411 | |||
| 12412 | ✗ | for(int32_t k=0; k<20; ++k) | |
| 12413 | { | ||
| 12414 | ✗ | x2=16*((zc_oldrand()%12)+2); | |
| 12415 | ✗ | y2=16*((zc_oldrand()%7)+2); | |
| 12416 | |||
| 12417 | ✗ | if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32)) | |
| 12418 | { | ||
| 12419 | ✗ | if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID)) | |
| 12420 | { | ||
| 12421 | ✗ | ((enemy*)guys.spr(kids+i))->count_enemy = false; | |
| 12422 | ✗ | if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z)) | |
| 12423 | { | ||
| 12424 | ✗ | ((enemy*)guys.spr(kids+i))->fakez = 64; | |
| 12425 | ✗ | ((enemy*)guys.spr(kids+i))->z = 0; | |
| 12426 | ✗ | } | |
| 12427 | ✗ | } | |
| 12428 | |||
| 12429 | ✗ | summoned=true; | |
| 12430 | ✗ | break; | |
| 12431 | } | ||
| 12432 | ✗ | } | |
| 12433 | ✗ | } | |
| 12434 | |||
| 12435 | ✗ | if(summoned) | |
| 12436 | { | ||
| 12437 | ✗ | sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x))); | |
| 12438 | ✗ | } | |
| 12439 | ✗ | } | |
| 12440 | ✗ | } | |
| 12441 | 128 | } | |
| 12442 | |||
| 12443 | |||
| 12444 | 39039 | void eWizzrobe::wizzrobe_attack() | |
| 12445 | { | ||
| 12446 |
8/12✓ Branch 0 taken 37747 times.
✓ Branch 1 taken 1292 times.
✓ Branch 2 taken 37747 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37747 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37540 times.
✓ Branch 7 taken 207 times.
✓ Branch 8 taken 37540 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 37540 times.
|
39039 | if(clk<0 || dying || stunclk || watch || ceiling || frozenclock) |
| 12447 | 1499 | return; | |
| 12448 | |||
| 12449 |
3/8✓ Branch 0 taken 36187 times.
✓ Branch 1 taken 1353 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36187 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
37540 | if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc)) |
| 12450 | { | ||
| 12451 | 1353 | fix_coords(); | |
| 12452 | |||
| 12453 |
5/5✓ Branch 0 taken 205 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 767 times.
✓ Branch 3 taken 148 times.
✓ Branch 4 taken 189 times.
|
1353 | switch(misc) |
| 12454 | { | ||
| 12455 | case 1: //walking | ||
| 12456 |
2/2✓ Branch 0 taken 84 times.
✓ Branch 1 taken 64 times.
|
148 | if(!m_walkflag(x,y,spw_door, dir)) |
| 12457 | 64 | misc=0; | |
| 12458 | else | ||
| 12459 | { | ||
| 12460 | 84 | clk3=16; | |
| 12461 | |||
| 12462 |
2/2✓ Branch 0 taken 82 times.
✓ Branch 1 taken 2 times.
|
84 | if(!canmove(dir,(zfix)1,spw_wizzrobe,false)) |
| 12463 | { | ||
| 12464 | 2 | wizzrobe_newdir(0); | |
| 12465 | 2 | } | |
| 12466 | } | ||
| 12467 | |||
| 12468 | 148 | break; | |
| 12469 | |||
| 12470 | case 2: //phasing | ||
| 12471 | { | ||
| 12472 | 189 | int32_t jx=x; | |
| 12473 | 189 | int32_t jy=y; | |
| 12474 | 189 | int32_t jdir=-1; | |
| 12475 | |||
| 12476 |
5/5✓ Branch 0 taken 98 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 18 times.
|
189 | switch(zc_oldrand()&7) |
| 12477 | { | ||
| 12478 | case 0: | ||
| 12479 | 32 | jx-=32; | |
| 12480 | 32 | jy-=32; | |
| 12481 | 32 | jdir=15; | |
| 12482 | 32 | break; | |
| 12483 | |||
| 12484 | case 1: | ||
| 12485 | 18 | jx+=32; | |
| 12486 | 18 | jy-=32; | |
| 12487 | 18 | jdir=9; | |
| 12488 | 18 | break; | |
| 12489 | |||
| 12490 | case 2: | ||
| 12491 | 23 | jx+=32; | |
| 12492 | 23 | jy+=32; | |
| 12493 | 23 | jdir=11; | |
| 12494 | 23 | break; | |
| 12495 | |||
| 12496 | case 3: | ||
| 12497 | 18 | jx-=32; | |
| 12498 | 18 | jy+=32; | |
| 12499 | 18 | jdir=13; | |
| 12500 | 18 | break; | |
| 12501 | } | ||
| 12502 | |||
| 12503 |
10/10✓ Branch 0 taken 91 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 83 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 71 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 51 times.
✓ Branch 9 taken 9 times.
|
189 | if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128) |
| 12504 | { | ||
| 12505 | 51 | misc=3; | |
| 12506 | 51 | clk3=32; | |
| 12507 | 51 | dir=jdir; | |
| 12508 | 51 | break; | |
| 12509 | } | ||
| 12510 | 138 | } | |
| 12511 | [[fallthrough]]; | ||
| 12512 | case 3: | ||
| 12513 | 182 | dir&=3; | |
| 12514 | 182 | misc=0; | |
| 12515 | [[fallthrough]]; | ||
| 12516 | case 0: | ||
| 12517 | 949 | wizzrobe_newdir(64); | |
| 12518 | [[fallthrough]]; | ||
| 12519 | default: | ||
| 12520 |
2/2✓ Branch 0 taken 1075 times.
✓ Branch 1 taken 79 times.
|
1154 | if(!canmove(dir,(zfix)1,spw_door,false)) |
| 12521 | { | ||
| 12522 |
2/2✓ Branch 0 taken 76 times.
✓ Branch 1 taken 3 times.
|
79 | if(canmove(dir,(zfix)15,spw_wizzrobe,false)) |
| 12523 | { | ||
| 12524 | 76 | misc=1; | |
| 12525 | 76 | clk3=16; | |
| 12526 | 76 | } | |
| 12527 | else | ||
| 12528 | { | ||
| 12529 | 3 | wizzrobe_newdir(64); | |
| 12530 | 3 | misc=0; | |
| 12531 | 3 | clk3=32; | |
| 12532 | } | ||
| 12533 | 79 | } | |
| 12534 | else | ||
| 12535 | { | ||
| 12536 | 1075 | clk3=32; | |
| 12537 | } | ||
| 12538 | |||
| 12539 | 1154 | break; | |
| 12540 | } | ||
| 12541 | |||
| 12542 |
2/2✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 189 times.
|
1353 | if(misc<0) |
| 12543 | 189 | ++misc; | |
| 12544 | 1353 | } | |
| 12545 | |||
| 12546 | 37540 | --clk3; | |
| 12547 | |||
| 12548 |
3/3✓ Branch 0 taken 3948 times.
✓ Branch 1 taken 30598 times.
✓ Branch 2 taken 2994 times.
|
37540 | switch(misc) |
| 12549 | { | ||
| 12550 | case 1: | ||
| 12551 | case 3: | ||
| 12552 | 3948 | step=1; | |
| 12553 | 3948 | break; | |
| 12554 | |||
| 12555 | case 2: | ||
| 12556 | 2994 | step=0; | |
| 12557 | 2994 | break; | |
| 12558 | |||
| 12559 | default: | ||
| 12560 | 30598 | step=0.5; | |
| 12561 | 30598 | break; | |
| 12562 | |||
| 12563 | } | ||
| 12564 | |||
| 12565 | 37540 | move(step); | |
| 12566 | |||
| 12567 | // if(d->misc1 && misc<=0 && clk3==28) | ||
| 12568 |
5/6✓ Branch 0 taken 37540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30598 times.
✓ Branch 3 taken 6942 times.
✓ Branch 4 taken 29544 times.
✓ Branch 5 taken 1054 times.
|
37540 | if(dmisc1 && misc<=0 && clk3==28) |
| 12569 | { | ||
| 12570 |
2/2✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 30 times.
|
1054 | if(dmisc2 != 1) |
| 12571 | { | ||
| 12572 |
2/2✓ Branch 0 taken 964 times.
✓ Branch 1 taken 60 times.
|
1024 | if(lined_up(8,false) == dir) |
| 12573 | { | ||
| 12574 | // addEwpn(x,y,z,wpn,0,wdp,dir,getUID()); | ||
| 12575 | // sfx(WAV_WAND,pan(int32_t(x))); | ||
| 12576 | 60 | wizzrobe_attack_for_real(); | |
| 12577 | 60 | fclk=30; | |
| 12578 | 60 | } | |
| 12579 | 1024 | } | |
| 12580 | else | ||
| 12581 | { | ||
| 12582 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
|
30 | if((zc_oldrand()%500)>=400) |
| 12583 | { | ||
| 12584 | 6 | wizzrobe_attack_for_real(); | |
| 12585 | 6 | fclk=30; | |
| 12586 | 6 | } | |
| 12587 | } | ||
| 12588 | 1054 | } | |
| 12589 | |||
| 12590 |
4/4✓ Branch 0 taken 26465 times.
✓ Branch 1 taken 11075 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 26272 times.
|
37540 | if(misc==0 && (zc_oldrand()&127)==0) |
| 12591 | 193 | misc=2; | |
| 12592 | |||
| 12593 |
4/4✓ Branch 0 taken 3187 times.
✓ Branch 1 taken 34353 times.
✓ Branch 2 taken 3020 times.
✓ Branch 3 taken 167 times.
|
37540 | if(misc==2 && clk3==4) |
| 12594 | 167 | fix_coords(); | |
| 12595 | |||
| 12596 |
2/4✓ Branch 0 taken 37540 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37540 times.
|
37540 | if(!(charging||firing)) //should never be charging or firing for these wizzrobes |
| 12597 | { | ||
| 12598 |
2/2✓ Branch 0 taken 35716 times.
✓ Branch 1 taken 1824 times.
|
37540 | if(fclk>0) |
| 12599 | { | ||
| 12600 | 1824 | --fclk; | |
| 12601 | 1824 | } | |
| 12602 | 37540 | } | |
| 12603 | |||
| 12604 | 39039 | } | |
| 12605 | |||
| 12606 | 954 | void eWizzrobe::wizzrobe_newdir(int32_t homing) | |
| 12607 | { | ||
| 12608 | // Wizzrobes shouldn't move to the edge of the screen; | ||
| 12609 | // if they're already there, they should move toward the center | ||
| 12610 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 954 times.
|
954 | if(x<32) |
| 12611 | ✗ | dir=right; | |
| 12612 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 954 times.
|
954 | else if(x>=224) |
| 12613 | ✗ | dir=left; | |
| 12614 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 954 times.
|
954 | else if(y<32) |
| 12615 | ✗ | dir=down; | |
| 12616 |
1/2✓ Branch 0 taken 954 times.
✗ Branch 1 not taken.
|
954 | else if(y>=144) |
| 12617 | ✗ | dir=up; | |
| 12618 | else | ||
| 12619 | 954 | newdir(4,homing,spw_wizzrobe); | |
| 12620 | 954 | } | |
| 12621 | |||
| 12622 | 53500 | void eWizzrobe::draw(BITMAP *dest) | |
| 12623 | { | ||
| 12624 | // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing | ||
| 12625 |
12/14✓ Branch 0 taken 39444 times.
✓ Branch 1 taken 14056 times.
✓ Branch 2 taken 36908 times.
✓ Branch 3 taken 2536 times.
✓ Branch 4 taken 2076 times.
✓ Branch 5 taken 37368 times.
✓ Branch 6 taken 2037 times.
✓ Branch 7 taken 39 times.
✓ Branch 8 taken 1968 times.
✓ Branch 9 taken 69 times.
✓ Branch 10 taken 1968 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1968 times.
✗ Branch 13 not taken.
|
53500 | if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing |
| 12626 | 1968 | return; | |
| 12627 | |||
| 12628 | 51532 | int32_t tempint=dummy_int[1]; | |
| 12629 | 51532 | bool tempbool1=dummy_bool[1]; | |
| 12630 | 51532 | bool tempbool2=dummy_bool[2]; | |
| 12631 | 51532 | dummy_int[1]=fclk; | |
| 12632 | 51532 | dummy_bool[1]=charging; | |
| 12633 | 51532 | dummy_bool[2]=firing; | |
| 12634 | 51532 | update_enemy_frame(); | |
| 12635 | 51532 | dummy_int[1]=tempint; | |
| 12636 | 51532 | dummy_bool[1]=tempbool1; | |
| 12637 | 51532 | dummy_bool[2]=tempbool2; | |
| 12638 | 51532 | enemy::draw(dest); | |
| 12639 | 53500 | } | |
| 12640 | |||
| 12641 | /*********************************/ | ||
| 12642 | /********** Bosses ***********/ | ||
| 12643 | /*********************************/ | ||
| 12644 | |||
| 12645 | 7 | eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 12646 | 7 | { | |
| 12647 | 7 | fading=fade_flash_die; | |
| 12648 | //nets+5120; | ||
| 12649 |
5/8✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
|
7 | if(dir==down&&y>=128) |
| 12650 | { | ||
| 12651 | ✗ | dir=up; | |
| 12652 | ✗ | } | |
| 12653 | |||
| 12654 |
5/8✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
|
7 | if(dir==right&&x>=208) |
| 12655 | { | ||
| 12656 | ✗ | dir=left; | |
| 12657 | ✗ | } | |
| 12658 | 7 | SIZEflags = d->SIZEflags; | |
| 12659 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 12660 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 12661 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 12662 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 12663 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 12664 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 12665 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 12666 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 12667 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 12668 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 12669 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 12670 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 12671 | { | ||
| 12672 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 12673 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 12674 | ✗ | } | |
| 12675 | |||
| 12676 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs; |
| 12677 | 7 | } | |
| 12678 | |||
| 12679 | 1324 | bool eDodongo::animate(int32_t index) | |
| 12680 | { | ||
| 12681 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
|
1324 | if(switch_hooked) return enemy::animate(index); |
| 12682 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1306 times.
|
1324 | if(dying) |
| 12683 | { | ||
| 12684 | 18 | return Dead(index); | |
| 12685 | } | ||
| 12686 | |||
| 12687 |
2/2✓ Branch 0 taken 1299 times.
✓ Branch 1 taken 7 times.
|
1306 | if(clk==0) |
| 12688 | { | ||
| 12689 | 7 | removearmos(x,y,ffcactivated); | |
| 12690 | 7 | } | |
| 12691 | |||
| 12692 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 1210 times.
|
1306 | if(clk2) // ate a bomb |
| 12693 | { | ||
| 12694 |
2/2✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1 times.
|
96 | if(--clk2==0) |
| 12695 | 1 | hp-=misc; // store bomb's power in misc | |
| 12696 | 96 | } | |
| 12697 | else | ||
| 12698 | 1210 | constant_walk(rate,homing,spw_clipright); | |
| 12699 | |||
| 12700 | 1306 | hit_width = (dir<=down) ? 16 : 32; | |
| 12701 | // hysz = (dir>=left) ? 16 : 32; | ||
| 12702 | |||
| 12703 | 1306 | return enemy::animate(index); | |
| 12704 | 1324 | } | |
| 12705 | |||
| 12706 | 1321 | void eDodongo::draw(BITMAP *dest) | |
| 12707 | { | ||
| 12708 | 1321 | tile=o_tile; | |
| 12709 | |||
| 12710 |
2/2✓ Branch 0 taken 111 times.
✓ Branch 1 taken 1210 times.
|
1321 | if(clk<0) |
| 12711 | { | ||
| 12712 | 111 | enemy::drawzcboss(dest); | |
| 12713 | 111 | return; | |
| 12714 | } | ||
| 12715 | |||
| 12716 | 1210 | update_enemy_frame(); | |
| 12717 | 1210 | enemy::drawzcboss(dest); | |
| 12718 | |||
| 12719 |
2/2✓ Branch 0 taken 733 times.
✓ Branch 1 taken 477 times.
|
1210 | if(dummy_int[1]!=0) //additional tiles |
| 12720 | { | ||
| 12721 | 477 | tile+=dummy_int[1]; //second tile is previous tile | |
| 12722 | 477 | xofs-=16; //new xofs change | |
| 12723 | 477 | enemy::drawzcboss(dest); | |
| 12724 | 477 | xofs+=16; | |
| 12725 | 477 | } | |
| 12726 | |||
| 12727 | 1321 | } | |
| 12728 | |||
| 12729 | 96 | int32_t eDodongo::takehit(weapon *w, weapon* realweap) | |
| 12730 | { | ||
| 12731 | 96 | int32_t wpnId = w->id; | |
| 12732 | 96 | int32_t power = w->power; | |
| 12733 | 96 | int32_t wpnx = w->x; | |
| 12734 | 96 | int32_t wpny = w->y; | |
| 12735 | |||
| 12736 |
5/12✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 71 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 25 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
96 | if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb))) |
| 12737 | 71 | return 0; | |
| 12738 | |||
| 12739 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
25 | switch(wpnId) |
| 12740 | { | ||
| 12741 | case wPhantom: | ||
| 12742 | ✗ | return 0; | |
| 12743 | |||
| 12744 | case wFire: | ||
| 12745 | case wBait: | ||
| 12746 | case wWhistle: | ||
| 12747 | case wWind: | ||
| 12748 | case wSSparkle: | ||
| 12749 | case wFSparkle: | ||
| 12750 | ✗ | return 0; | |
| 12751 | |||
| 12752 | case wLitBomb: | ||
| 12753 | case wLitSBomb: | ||
| 12754 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7) |
| 12755 | ✗ | return 0; | |
| 12756 | |||
| 12757 | 1 | clk2=96; | |
| 12758 | 1 | misc=power; | |
| 12759 | |||
| 12760 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(wpnId==wLitSBomb) |
| 12761 | ✗ | item_set=isSBOMB100; | |
| 12762 | |||
| 12763 | 1 | return 1; | |
| 12764 | |||
| 12765 | case wBomb: | ||
| 12766 | case wSBomb: | ||
| 12767 |
6/6✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 9 times.
|
23 | if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8) |
| 12768 | 14 | return 0; | |
| 12769 | |||
| 12770 | 9 | stunclk=160; | |
| 12771 | 9 | misc=wpnId; // store wpnId | |
| 12772 | 9 | return 1; | |
| 12773 | |||
| 12774 | case wSword: | ||
| 12775 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(stunclk) |
| 12776 | { | ||
| 12777 | 1 | sfx(WAV_EHIT,pan(int32_t(x))); | |
| 12778 | 1 | hp=0; | |
| 12779 | 1 | item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100; | |
| 12780 | 1 | fading=0; // don't flash | |
| 12781 | 1 | return 1; | |
| 12782 | } | ||
| 12783 | |||
| 12784 | [[fallthrough]]; | ||
| 12785 | default: | ||
| 12786 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 12787 | ✗ | } | |
| 12788 | |||
| 12789 | ✗ | return 1; | |
| 12790 | 96 | } | |
| 12791 | |||
| 12792 | ✗ | eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 12793 | ✗ | { | |
| 12794 | ✗ | fading=fade_flash_die; | |
| 12795 | //nets+5180; | ||
| 12796 | ✗ | previous_dir=-1; | |
| 12797 | ✗ | if(dir==down&&y>=128) | |
| 12798 | { | ||
| 12799 | ✗ | dir=up; | |
| 12800 | ✗ | } | |
| 12801 | |||
| 12802 | ✗ | if(dir==right&&x>=208) | |
| 12803 | { | ||
| 12804 | ✗ | dir=left; | |
| 12805 | ✗ | } | |
| 12806 | ✗ | SIZEflags = d->SIZEflags; | |
| 12807 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. | |
| 12808 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 12809 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 12810 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } | |
| 12811 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; | |
| 12812 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; | |
| 12813 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; | |
| 12814 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; | |
| 12815 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; | |
| 12816 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 12817 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; | |
| 12818 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) | |
| 12819 | { | ||
| 12820 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 12821 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 12822 | ✗ | } | |
| 12823 | |||
| 12824 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs; | |
| 12825 | ✗ | } | |
| 12826 | |||
| 12827 | ✗ | bool eDodongo2::animate(int32_t index) | |
| 12828 | { | ||
| 12829 | ✗ | if(switch_hooked) return enemy::animate(index); | |
| 12830 | ✗ | if(dying) | |
| 12831 | { | ||
| 12832 | ✗ | return Dead(index); | |
| 12833 | } | ||
| 12834 | |||
| 12835 | ✗ | if(clk==0) | |
| 12836 | { | ||
| 12837 | ✗ | removearmos(x,y,ffcactivated); | |
| 12838 | ✗ | } | |
| 12839 | |||
| 12840 | ✗ | if(clk2) // ate a bomb | |
| 12841 | { | ||
| 12842 | ✗ | if(--clk2==0) | |
| 12843 | ✗ | hp-=misc; // store bomb's power in misc | |
| 12844 | ✗ | } | |
| 12845 | else | ||
| 12846 | ✗ | constant_walk(rate,homing,spw_clipbottomright); | |
| 12847 | |||
| 12848 | ✗ | hit_width = (dir<=down) ? 16 : 32; | |
| 12849 | ✗ | hit_height = (dir>=left) ? 16 : 32; | |
| 12850 | ✗ | hxofs=(dir>=left)?-8:0; | |
| 12851 | ✗ | hyofs=(dir<left)?-8:0; | |
| 12852 | |||
| 12853 | ✗ | return enemy::animate(index); | |
| 12854 | ✗ | } | |
| 12855 | |||
| 12856 | ✗ | void eDodongo2::draw(BITMAP *dest) | |
| 12857 | { | ||
| 12858 | ✗ | if(clk<0) | |
| 12859 | { | ||
| 12860 | ✗ | enemy::drawzcboss(dest); | |
| 12861 | ✗ | return; | |
| 12862 | } | ||
| 12863 | |||
| 12864 | ✗ | int32_t tempx=xofs; | |
| 12865 | ✗ | int32_t tempy=yofs; | |
| 12866 | ✗ | update_enemy_frame(); | |
| 12867 | ✗ | enemy::drawzcboss(dest); | |
| 12868 | ✗ | tile+=dummy_int[1]; //second tile change | |
| 12869 | ✗ | xofs+=dummy_int[2]; //new xofs change | |
| 12870 | ✗ | yofs+=dummy_int[3]; //new yofs change | |
| 12871 | ✗ | enemy::drawzcboss(dest); | |
| 12872 | ✗ | xofs=tempx; | |
| 12873 | ✗ | yofs=tempy; | |
| 12874 | ✗ | } | |
| 12875 | |||
| 12876 | ✗ | int32_t eDodongo2::takehit(weapon *w, weapon* realweap) | |
| 12877 | { | ||
| 12878 | ✗ | int32_t wpnId = w->id; | |
| 12879 | ✗ | int32_t power = w->power; | |
| 12880 | ✗ | int32_t wpnx = w->x; | |
| 12881 | ✗ | int32_t wpny = w->y; | |
| 12882 | |||
| 12883 | ✗ | if(dying || clk<0 || clk2>0 || superman) | |
| 12884 | ✗ | return 0; | |
| 12885 | |||
| 12886 | ✗ | switch(wpnId) | |
| 12887 | { | ||
| 12888 | case wPhantom: | ||
| 12889 | ✗ | return 0; | |
| 12890 | |||
| 12891 | case wFire: | ||
| 12892 | case wBait: | ||
| 12893 | case wWhistle: | ||
| 12894 | case wWind: | ||
| 12895 | case wSSparkle: | ||
| 12896 | case wFSparkle: | ||
| 12897 | ✗ | return 0; | |
| 12898 | |||
| 12899 | case wLitBomb: | ||
| 12900 | case wLitSBomb: | ||
| 12901 | ✗ | switch(dir) | |
| 12902 | { | ||
| 12903 | case up: | ||
| 12904 | ✗ | if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7) | |
| 12905 | ✗ | return 0; | |
| 12906 | |||
| 12907 | ✗ | break; | |
| 12908 | |||
| 12909 | case down: | ||
| 12910 | ✗ | if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7) | |
| 12911 | ✗ | return 0; | |
| 12912 | |||
| 12913 | ✗ | break; | |
| 12914 | |||
| 12915 | case left: | ||
| 12916 | ✗ | if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7) | |
| 12917 | ✗ | return 0; | |
| 12918 | |||
| 12919 | ✗ | break; | |
| 12920 | |||
| 12921 | case right: | ||
| 12922 | ✗ | if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7) | |
| 12923 | ✗ | return 0; | |
| 12924 | |||
| 12925 | ✗ | break; | |
| 12926 | } | ||
| 12927 | |||
| 12928 | // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7) | ||
| 12929 | // return 0; | ||
| 12930 | ✗ | clk2=96; | |
| 12931 | ✗ | misc=power; | |
| 12932 | |||
| 12933 | ✗ | if(wpnId==wLitSBomb) | |
| 12934 | ✗ | item_set=isSBOMB100; | |
| 12935 | |||
| 12936 | ✗ | return 1; | |
| 12937 | |||
| 12938 | case wBomb: | ||
| 12939 | case wSBomb: | ||
| 12940 | ✗ | switch(dir) | |
| 12941 | { | ||
| 12942 | case up: | ||
| 12943 | ✗ | if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7) | |
| 12944 | ✗ | return 0; | |
| 12945 | |||
| 12946 | ✗ | break; | |
| 12947 | |||
| 12948 | case down: | ||
| 12949 | ✗ | if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7) | |
| 12950 | ✗ | return 0; | |
| 12951 | |||
| 12952 | ✗ | break; | |
| 12953 | |||
| 12954 | case left: | ||
| 12955 | ✗ | if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7) | |
| 12956 | ✗ | return 0; | |
| 12957 | |||
| 12958 | ✗ | break; | |
| 12959 | |||
| 12960 | case right: | ||
| 12961 | ✗ | if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7) | |
| 12962 | ✗ | return 0; | |
| 12963 | |||
| 12964 | ✗ | break; | |
| 12965 | } | ||
| 12966 | |||
| 12967 | ✗ | stunclk=160; | |
| 12968 | ✗ | misc=wpnId; // store wpnId | |
| 12969 | ✗ | return 1; | |
| 12970 | |||
| 12971 | case wSword: | ||
| 12972 | ✗ | if(stunclk) | |
| 12973 | { | ||
| 12974 | ✗ | sfx(WAV_EHIT,pan(int32_t(x))); | |
| 12975 | ✗ | hp=0; | |
| 12976 | ✗ | item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100; | |
| 12977 | ✗ | fading=0; // don't flash | |
| 12978 | ✗ | return 1; | |
| 12979 | } | ||
| 12980 | |||
| 12981 | [[fallthrough]]; | ||
| 12982 | default: | ||
| 12983 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 12984 | ✗ | } | |
| 12985 | |||
| 12986 | ✗ | return 1; | |
| 12987 | ✗ | } | |
| 12988 | |||
| 12989 | 7 | eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk) | |
| 12990 | 7 | { | |
| 12991 | //these are here to bypass compiler warnings about unused arguments | ||
| 12992 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if ( !(editorflags & ENEMY_FLAG5) ) |
| 12993 | { | ||
| 12994 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | x = dmisc1 ? 64 : 176; |
| 12995 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | y = 64; |
| 12996 | 7 | } | |
| 12997 | ✗ | else { x = X; y = Y; } | |
| 12998 | |||
| 12999 | //nets+5940; | ||
| 13000 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5 times.
|
7 | if(get_qr(qr_NEWENEMYTILES)) |
| 13001 | { | ||
| 13002 | 2 | } | |
| 13003 | else | ||
| 13004 | { | ||
| 13005 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | if(dmisc1) |
| 13006 | { | ||
| 13007 | ✗ | flip=1; | |
| 13008 | ✗ | } | |
| 13009 | } | ||
| 13010 | |||
| 13011 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
7 | yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1; |
| 13012 | 7 | clk3=32; | |
| 13013 | 7 | clk2=0; | |
| 13014 | 7 | clk4=clk; | |
| 13015 | 7 | dir=left; | |
| 13016 | 7 | SIZEflags = d->SIZEflags; | |
| 13017 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 13018 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 13019 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 13020 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 13021 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 13022 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 13023 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 13024 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 13025 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 13026 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 13027 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 13028 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 13029 | { | ||
| 13030 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 13031 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 13032 | ✗ | } | |
| 13033 | |||
| 13034 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; |
| 13035 | 7 | } | |
| 13036 | |||
| 13037 | 3900 | bool eAquamentus::animate(int32_t index) | |
| 13038 | { | ||
| 13039 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3900 times.
|
3900 | if(switch_hooked) return enemy::animate(index); |
| 13040 |
2/2✓ Branch 0 taken 108 times.
✓ Branch 1 taken 3792 times.
|
3900 | if(dying) |
| 13041 | 108 | return Dead(index); | |
| 13042 | |||
| 13043 | // fbx=x+((id==eRAQUAM)?4:-4); | ||
| 13044 |
2/2✓ Branch 0 taken 3774 times.
✓ Branch 1 taken 18 times.
|
3792 | if(clk==0) |
| 13045 | { | ||
| 13046 | 18 | removearmos(x,y,ffcactivated); | |
| 13047 | 18 | } | |
| 13048 | |||
| 13049 | 3792 | fbx=x; | |
| 13050 | |||
| 13051 | /* | ||
| 13052 | if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM) | ||
| 13053 | { | ||
| 13054 | fbx+=16; | ||
| 13055 | } | ||
| 13056 | */ | ||
| 13057 |
2/2✓ Branch 0 taken 3765 times.
✓ Branch 1 taken 27 times.
|
3792 | if(--clk3==0) |
| 13058 | { | ||
| 13059 | // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1); | ||
| 13060 | // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0); | ||
| 13061 | // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1); | ||
| 13062 | 27 | addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez); | |
| 13063 | 27 | addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez); | |
| 13064 | 27 | addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez); | |
| 13065 | 27 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 13066 | 27 | } | |
| 13067 | |||
| 13068 |
4/4✓ Branch 0 taken 855 times.
✓ Branch 1 taken 2937 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 835 times.
|
3792 | if(clk3<-80 && !(zc_oldrand()&63)) |
| 13069 | { | ||
| 13070 | 20 | clk3=32; | |
| 13071 | 20 | } | |
| 13072 | |||
| 13073 |
2/2✓ Branch 0 taken 3730 times.
✓ Branch 1 taken 62 times.
|
3792 | if(!((clk4+1)&63)) |
| 13074 | { | ||
| 13075 | 62 | int32_t d2=(zc_oldrand()%3)+1; | |
| 13076 | |||
| 13077 |
2/2✓ Branch 0 taken 19 times.
✓ Branch 1 taken 43 times.
|
62 | if(d2>=left) |
| 13078 | { | ||
| 13079 | 43 | dir=d2; | |
| 13080 | 43 | } | |
| 13081 | |||
| 13082 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 49 times.
|
62 | if(dmisc1) |
| 13083 | { | ||
| 13084 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
|
13 | if(x<=40) |
| 13085 | { | ||
| 13086 | 1 | dir=right; | |
| 13087 | 1 | } | |
| 13088 | |||
| 13089 |
1/2✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
|
13 | if(x>=104) |
| 13090 | { | ||
| 13091 | ✗ | dir=left; | |
| 13092 | ✗ | } | |
| 13093 | 13 | } | |
| 13094 | else | ||
| 13095 | { | ||
| 13096 |
1/2✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
|
49 | if(x<=136) |
| 13097 | { | ||
| 13098 | ✗ | dir=right; | |
| 13099 | ✗ | } | |
| 13100 | |||
| 13101 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1 times.
|
49 | if(x>=200) |
| 13102 | { | ||
| 13103 | 1 | dir=left; | |
| 13104 | 1 | } | |
| 13105 | } | ||
| 13106 | 62 | } | |
| 13107 | |||
| 13108 |
4/4✓ Branch 0 taken 3694 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 3231 times.
✓ Branch 3 taken 463 times.
|
3792 | if(clk4>=-1 && !((clk4+1)&7)) |
| 13109 | { | ||
| 13110 |
2/2✓ Branch 0 taken 250 times.
✓ Branch 1 taken 213 times.
|
463 | if(dir==left) |
| 13111 | { | ||
| 13112 | 250 | x-=1; | |
| 13113 | 250 | } | |
| 13114 | else | ||
| 13115 | { | ||
| 13116 | 213 | x+=1; | |
| 13117 | } | ||
| 13118 | 463 | } | |
| 13119 | |||
| 13120 | 3792 | clk4=(clk4+1)%256; | |
| 13121 | |||
| 13122 | 3792 | return enemy::animate(index); | |
| 13123 | 3900 | } | |
| 13124 | |||
| 13125 | 3901 | void eAquamentus::draw(BITMAP *dest) | |
| 13126 | { | ||
| 13127 |
2/2✓ Branch 0 taken 1235 times.
✓ Branch 1 taken 2666 times.
|
3901 | if(get_qr(qr_NEWENEMYTILES)) |
| 13128 | { | ||
| 13129 | 1235 | xofs=(dmisc1?-16:0); | |
| 13130 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
✓ Branch 2 taken 512 times.
✓ Branch 3 taken 723 times.
|
1235 | if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0); |
| 13131 | |||
| 13132 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1217 times.
|
1235 | if(dying) |
| 13133 | { | ||
| 13134 | 18 | xofs=0; | |
| 13135 | 18 | enemy::draw(dest); | |
| 13136 | 18 | } | |
| 13137 | else | ||
| 13138 | { | ||
| 13139 | 1217 | drawblock(dest,15); | |
| 13140 | } | ||
| 13141 | 1235 | } | |
| 13142 | else | ||
| 13143 | { | ||
| 13144 | 2666 | int32_t xblockofs=((dmisc1)?-16:16); | |
| 13145 | 2666 | xofs=0; | |
| 13146 | |||
| 13147 |
4/4✓ Branch 0 taken 2591 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 2501 times.
|
2666 | if(clk<0 || dying) |
| 13148 | { | ||
| 13149 | 165 | enemy::draw(dest); | |
| 13150 | 165 | return; | |
| 13151 | } | ||
| 13152 |
1/2✓ Branch 0 taken 2501 times.
✗ Branch 1 not taken.
|
2501 | if ( do_animation ) |
| 13153 | { | ||
| 13154 | // face (0=firing, 2=resting) | ||
| 13155 | 2501 | tile=o_tile+((clk3>0)?0:2); | |
| 13156 | 2501 | enemy::draw(dest); | |
| 13157 | // tail ( | ||
| 13158 | 2501 | tile=o_tile+((clk&16)?1:3); | |
| 13159 | 2501 | xofs=xblockofs; | |
| 13160 | 2501 | enemy::draw(dest); | |
| 13161 | // body | ||
| 13162 | 2501 | yofs+=16; | |
| 13163 | 2501 | xofs=0; | |
| 13164 | 2501 | tile=o_tile+((clk&16)?20:22); | |
| 13165 | 2501 | enemy::draw(dest); | |
| 13166 | 2501 | xofs=xblockofs; | |
| 13167 | 2501 | tile=o_tile+((clk&16)?21:23); | |
| 13168 | 2501 | enemy::draw(dest); | |
| 13169 | 2501 | yofs-=16; | |
| 13170 | 2501 | } | |
| 13171 | ✗ | else enemy::draw(dest); | |
| 13172 | } | ||
| 13173 | 3901 | } | |
| 13174 | |||
| 13175 | 913 | bool eAquamentus::hit(weapon *w) | |
| 13176 | { | ||
| 13177 |
3/6✓ Branch 0 taken 913 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 913 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 913 times.
|
913 | if(!w->scriptcoldet || w->fallclk || w->drownclk) return false; |
| 13178 | |||
| 13179 |
2/2✓ Branch 0 taken 844 times.
✓ Branch 1 taken 69 times.
|
913 | switch(w->id) |
| 13180 | { | ||
| 13181 | case wBeam: | ||
| 13182 | case wRefBeam: | ||
| 13183 | case wMagic: | ||
| 13184 | 844 | hit_height=32; | |
| 13185 | 844 | } | |
| 13186 | |||
| 13187 |
4/4✓ Branch 0 taken 896 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 849 times.
✓ Branch 3 taken 47 times.
|
913 | bool ret = (dying || hclk>0) ? false : sprite::hit(w); |
| 13188 | 913 | hit_height=16; | |
| 13189 | 913 | return ret; | |
| 13190 | |||
| 13191 | 913 | } | |
| 13192 | |||
| 13193 | 2 | eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0) | |
| 13194 | 2 | { | |
| 13195 | |||
| 13196 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if ( !(editorflags & ENEMY_FLAG5) ) |
| 13197 | { | ||
| 13198 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | x = 128; |
| 13199 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | y = 48; |
| 13200 | 2 | } | |
| 13201 | ✗ | else { x = X; y = Y; } | |
| 13202 | |||
| 13203 | 2 | Clk=Clk; | |
| 13204 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(flags & guy_fadeflicker) |
| 13205 | { | ||
| 13206 | ✗ | clk=0; | |
| 13207 | ✗ | superman = 1; | |
| 13208 | ✗ | fading=fade_flicker; | |
| 13209 | ✗ | if (!(editorflags&ENEMY_FLAG3)) count_enemy=false; | |
| 13210 | ✗ | } | |
| 13211 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | else if(flags & guy_fadeinstant) |
| 13212 | { | ||
| 13213 | 2 | clk=0; | |
| 13214 | 2 | } | |
| 13215 | 2 | hxofs=-16; | |
| 13216 | 2 | hit_width=48; | |
| 13217 | 2 | clk4=0; | |
| 13218 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1; |
| 13219 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | dir=zc_oldrand()%3+1; |
| 13220 | 2 | SIZEflags = d->SIZEflags; | |
| 13221 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
2 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 13222 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 13223 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 13224 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
2 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; } |
| 13225 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width; |
| 13226 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height; |
| 13227 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz; |
| 13228 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs; |
| 13229 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs; |
| 13230 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 13231 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
2 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs; |
| 13232 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 13233 | { | ||
| 13234 | ✗ | yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 13235 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 13236 | ✗ | } | |
| 13237 | |||
| 13238 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
2 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs; |
| 13239 | |||
| 13240 | //nets+5340; | ||
| 13241 | 2 | } | |
| 13242 | |||
| 13243 | 1785 | bool eGohma::animate(int32_t index) | |
| 13244 | { | ||
| 13245 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
|
1785 | if(switch_hooked) return enemy::animate(index); |
| 13246 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 1749 times.
|
1785 | if(dying) |
| 13247 | 36 | return Dead(index); | |
| 13248 | |||
| 13249 |
1/2✓ Branch 0 taken 1749 times.
✗ Branch 1 not taken.
|
1749 | if(fading) |
| 13250 | { | ||
| 13251 | ✗ | if(++clk4 > 60) | |
| 13252 | { | ||
| 13253 | ✗ | clk4=0; | |
| 13254 | ✗ | superman=0; | |
| 13255 | ✗ | fading=0; | |
| 13256 | ✗ | clk=0; | |
| 13257 | |||
| 13258 | ✗ | } | |
| 13259 | ✗ | else return enemy::animate(index); | |
| 13260 | ✗ | } | |
| 13261 | |||
| 13262 |
2/2✓ Branch 0 taken 1741 times.
✓ Branch 1 taken 8 times.
|
1749 | if(clk==0) |
| 13263 | { | ||
| 13264 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | if (ffcactivated) removearmosffc(ffcactivated-1); |
| 13265 | else | ||
| 13266 | { | ||
| 13267 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
8 | removearmos(zc_max(x-16, 0_zf),y); |
| 13268 | 8 | did_armos = false; | |
| 13269 | 8 | removearmos(x,y); | |
| 13270 | 8 | did_armos = false; | |
| 13271 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | removearmos(zc_min(x+16, 255_zf),y); |
| 13272 | } | ||
| 13273 | 8 | } | |
| 13274 | |||
| 13275 |
1/2✓ Branch 0 taken 1749 times.
✗ Branch 1 not taken.
|
1749 | if(clk<0) return enemy::animate(index); |
| 13276 | |||
| 13277 | // Movement clk must be separate from animation clk because of the Clock item | ||
| 13278 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1749 times.
|
1749 | if(!watch) |
| 13279 | 1749 | clk4++; | |
| 13280 | |||
| 13281 |
2/2✓ Branch 0 taken 1723 times.
✓ Branch 1 taken 26 times.
|
1749 | if((clk4&63)==0) |
| 13282 | { | ||
| 13283 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 12 times.
|
26 | if(clk4&64) |
| 13284 | 14 | dir^=1; | |
| 13285 | else | ||
| 13286 | 12 | dir=zc_oldrand()%3+1; | |
| 13287 | 26 | } | |
| 13288 | |||
| 13289 |
2/2✓ Branch 0 taken 1721 times.
✓ Branch 1 taken 28 times.
|
1749 | if((clk&63)==3) |
| 13290 | { | ||
| 13291 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | switch(dmisc1) |
| 13292 | { | ||
| 13293 | case 1: | ||
| 13294 | ✗ | addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez); | |
| 13295 | ✗ | addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez); | |
| 13296 | ✗ | addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez); | |
| 13297 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 13298 | ✗ | break; | |
| 13299 | |||
| 13300 | default: | ||
| 13301 |
2/4✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
|
28 | if(dmisc1 != 1 && dmisc1 != 2) |
| 13302 | { | ||
| 13303 | 28 | addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez); | |
| 13304 | 28 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 13305 | 28 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 13306 | 28 | } | |
| 13307 | |||
| 13308 | 28 | break; | |
| 13309 | } | ||
| 13310 | 28 | } | |
| 13311 | |||
| 13312 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1749 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1749 | if((dmisc1 == 2)&& clk3>=16 && clk3<116) |
| 13313 | { | ||
| 13314 | ✗ | if(!(clk3%8)) | |
| 13315 | { | ||
| 13316 | ✗ | FireBreath(true); | |
| 13317 | ✗ | } | |
| 13318 | ✗ | } | |
| 13319 | |||
| 13320 |
2/2✓ Branch 0 taken 874 times.
✓ Branch 1 taken 875 times.
|
1749 | if(clk4&1) |
| 13321 | 875 | move((zfix)1); | |
| 13322 | |||
| 13323 |
2/2✓ Branch 0 taken 1745 times.
✓ Branch 1 taken 4 times.
|
1749 | if(++clk3>=400) |
| 13324 | 4 | clk3=0; | |
| 13325 | |||
| 13326 | 1749 | return enemy::animate(index); | |
| 13327 | 1785 | } | |
| 13328 | |||
| 13329 | 1785 | void eGohma::draw(BITMAP *dest) | |
| 13330 | { | ||
| 13331 | 1785 | tile=o_tile; | |
| 13332 | |||
| 13333 |
3/4✓ Branch 0 taken 1785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 1749 times.
|
1785 | if(clk<0 || dying) |
| 13334 | { | ||
| 13335 | 36 | enemy::drawzcboss(dest); | |
| 13336 | 36 | return; | |
| 13337 | } | ||
| 13338 | |||
| 13339 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1749 times.
|
1749 | if(get_qr(qr_NEWENEMYTILES)) |
| 13340 | { | ||
| 13341 | ///if ( do_animation ) | ||
| 13342 | //Yuck. Gohma can just not have this capability right now. | ||
| 13343 | // left side | ||
| 13344 | ✗ | xofs=-16; | |
| 13345 | ✗ | flip=0; | |
| 13346 | // if(clk&16) tile=180; | ||
| 13347 | // else { tile=182; flip=1; } | ||
| 13348 | ✗ | tile+=(3*((clk&48)>>4)); | |
| 13349 | ✗ | enemy::drawzcboss(dest); | |
| 13350 | |||
| 13351 | // right side | ||
| 13352 | ✗ | xofs=16; | |
| 13353 | // tile=(180+182)-tile; | ||
| 13354 | ✗ | tile=o_tile; | |
| 13355 | ✗ | tile+=(3*((clk&48)>>4))+2; | |
| 13356 | ✗ | enemy::drawzcboss(dest); | |
| 13357 | |||
| 13358 | // body | ||
| 13359 | ✗ | xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020 | |
| 13360 | ✗ | tile=o_tile; | |
| 13361 | |||
| 13362 | // tile+=(3*((clk&24)>>3))+2; | ||
| 13363 | ✗ | if(clk3<16) | |
| 13364 | ✗ | tile+=7; | |
| 13365 | ✗ | else if(clk3<116) | |
| 13366 | ✗ | tile+=10; | |
| 13367 | ✗ | else if(clk3<132) | |
| 13368 | ✗ | tile+=7; | |
| 13369 | else | ||
| 13370 | ✗ | tile+=((clk3-132)&24)?4:1; | |
| 13371 | |||
| 13372 | ✗ | enemy::drawzcboss(dest); | |
| 13373 | |||
| 13374 | ✗ | } | |
| 13375 | else | ||
| 13376 | { | ||
| 13377 | // left side | ||
| 13378 | 1749 | xofs=-16; | |
| 13379 | 1749 | flip=0; | |
| 13380 | |||
| 13381 |
2/2✓ Branch 0 taken 864 times.
✓ Branch 1 taken 885 times.
|
1749 | if(!(clk&16)) |
| 13382 | { | ||
| 13383 | 885 | tile+=2; | |
| 13384 | 885 | flip=1; | |
| 13385 | 885 | } | |
| 13386 | |||
| 13387 | 1749 | enemy::draw(dest); | |
| 13388 | |||
| 13389 | // right side | ||
| 13390 | 1749 | tile=o_tile; | |
| 13391 | 1749 | xofs=16; | |
| 13392 | |||
| 13393 |
2/2✓ Branch 0 taken 885 times.
✓ Branch 1 taken 864 times.
|
1749 | if((clk&16)) tile+=2; |
| 13394 | |||
| 13395 | // tile=(180+182)-tile; | ||
| 13396 | 1749 | enemy::draw(dest); | |
| 13397 | |||
| 13398 | // body | ||
| 13399 | 1749 | tile=o_tile; | |
| 13400 | 1749 | xofs=0; | |
| 13401 | |||
| 13402 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 1653 times.
|
1749 | if(clk3<16) |
| 13403 | 96 | tile+=4; | |
| 13404 |
2/2✓ Branch 0 taken 517 times.
✓ Branch 1 taken 1136 times.
|
1653 | else if(clk3<116) |
| 13405 | 517 | tile+=5; | |
| 13406 |
2/2✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1072 times.
|
1136 | else if(clk3<132) |
| 13407 | 64 | tile+=4; | |
| 13408 | 1072 | else tile+=((clk3-132)&8)?3:1; | |
| 13409 | |||
| 13410 | 1749 | enemy::draw(dest); | |
| 13411 | |||
| 13412 | } | ||
| 13413 | 1785 | } | |
| 13414 | |||
| 13415 | 8 | int32_t eGohma::takehit(weapon *w, weapon* realweap) | |
| 13416 | { | ||
| 13417 | 8 | int32_t wpnId = w->id; | |
| 13418 | 8 | int32_t power = w->power; | |
| 13419 | 8 | int32_t wpnx = w->x; | |
| 13420 | 8 | int32_t wpnDir = w->dir; | |
| 13421 | 8 | int32_t def = defenditemclassNew(wpnId, &power, w, realweap); | |
| 13422 | |||
| 13423 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
|
8 | if(def < 0) |
| 13424 | { | ||
| 13425 |
6/10✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 2 times.
|
6 | if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116)) |
| 13426 | { | ||
| 13427 | 4 | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 13428 | 4 | return 1; | |
| 13429 | } | ||
| 13430 | 2 | } | |
| 13431 | |||
| 13432 | 4 | return enemy::takehit(w, realweap); | |
| 13433 | 8 | } | |
| 13434 | |||
| 13435 | 4 | eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 13436 | 4 | { | |
| 13437 | 4 | count_enemy=(id==(id&0xFFF)); | |
| 13438 | //nets+4360+(((id&0xFF)-eDIGPUP2)*40); | ||
| 13439 | 4 | SIZEflags = d->SIZEflags; | |
| 13440 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 13441 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 13442 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 13443 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 13444 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 13445 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 13446 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 13447 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 13448 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 13449 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 13450 |
1/4✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 13451 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 13452 | { | ||
| 13453 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 13454 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 13455 | ✗ | } | |
| 13456 | |||
| 13457 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; |
| 13458 | 4 | } | |
| 13459 | |||
| 13460 | 781 | bool eLilDig::animate(int32_t index) | |
| 13461 | { | ||
| 13462 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 781 times.
|
781 | if(switch_hooked) return enemy::animate(index); |
| 13463 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 709 times.
|
781 | if(dying) |
| 13464 | 72 | return Dead(index); | |
| 13465 | |||
| 13466 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 653 times.
|
709 | if(clk==0) |
| 13467 | { | ||
| 13468 | 56 | removearmos(x,y,ffcactivated); | |
| 13469 | 56 | } | |
| 13470 | |||
| 13471 |
2/2✓ Branch 0 taken 193 times.
✓ Branch 1 taken 516 times.
|
709 | if(misc<=128) |
| 13472 | { | ||
| 13473 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 500 times.
|
516 | if(!(++misc&31)) |
| 13474 | 16 | step+=0.25; | |
| 13475 | 516 | } | |
| 13476 | |||
| 13477 | 709 | variable_walk_8(rate,homing,hrate,spw_floater); | |
| 13478 | 709 | return enemy::animate(index); | |
| 13479 | 781 | } | |
| 13480 | |||
| 13481 | 777 | void eLilDig::draw(BITMAP *dest) | |
| 13482 | { | ||
| 13483 | 777 | tile = o_tile; | |
| 13484 | // tile = 160; | ||
| 13485 | 777 | int32_t fdiv = frate/4; | |
| 13486 |
1/2✓ Branch 0 taken 777 times.
✗ Branch 1 not taken.
|
777 | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; |
| 13487 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
|
777 | int32_t f2=get_qr(qr_NEWENEMYTILES)? |
| 13488 | 777 | efrate:((clk>=(frate>>1))?1:0); | |
| 13489 | |||
| 13490 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
|
777 | if ( do_animation ) |
| 13491 | { | ||
| 13492 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
|
777 | if(get_qr(qr_NEWENEMYTILES)) |
| 13493 | { | ||
| 13494 | ✗ | switch(dir-8) //directions get screwed up after 8. *shrug* | |
| 13495 | { | ||
| 13496 | case up: //u | ||
| 13497 | ✗ | flip=0; | |
| 13498 | ✗ | break; | |
| 13499 | |||
| 13500 | case l_up: //d | ||
| 13501 | ✗ | flip=0; | |
| 13502 | ✗ | tile+=4; | |
| 13503 | ✗ | break; | |
| 13504 | |||
| 13505 | case l_down: //l | ||
| 13506 | ✗ | flip=0; | |
| 13507 | ✗ | tile+=8; | |
| 13508 | ✗ | break; | |
| 13509 | |||
| 13510 | case left: //r | ||
| 13511 | ✗ | flip=0; | |
| 13512 | ✗ | tile+=12; | |
| 13513 | ✗ | break; | |
| 13514 | |||
| 13515 | case r_down: //ul | ||
| 13516 | ✗ | flip=0; | |
| 13517 | ✗ | tile+=20; | |
| 13518 | ✗ | break; | |
| 13519 | |||
| 13520 | case down: //ur | ||
| 13521 | ✗ | flip=0; | |
| 13522 | ✗ | tile+=24; | |
| 13523 | ✗ | break; | |
| 13524 | |||
| 13525 | case r_up: //dl | ||
| 13526 | ✗ | flip=0; | |
| 13527 | ✗ | tile+=28; | |
| 13528 | ✗ | break; | |
| 13529 | |||
| 13530 | case right: //dr | ||
| 13531 | ✗ | flip=0; | |
| 13532 | ✗ | tile+=32; | |
| 13533 | ✗ | break; | |
| 13534 | } | ||
| 13535 | |||
| 13536 | ✗ | tile+=f2; | |
| 13537 | ✗ | } | |
| 13538 | else | ||
| 13539 | { | ||
| 13540 | 777 | tile+=(clk>=6)?1:0; | |
| 13541 | } | ||
| 13542 | 777 | } | |
| 13543 | |||
| 13544 | 777 | enemy::draw(dest); | |
| 13545 | 777 | } | |
| 13546 | |||
| 13547 | 3 | eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 13548 | 3 | { | |
| 13549 | 3 | superman=1; | |
| 13550 | |||
| 13551 | 3 | SIZEflags = d->SIZEflags; | |
| 13552 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
3 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 13553 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 13554 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 13555 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
3 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 13556 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 13557 | 3 | else hit_width=32; | |
| 13558 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 13559 | 3 | else hit_height=32; | |
| 13560 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 13561 | 3 | else hzsz=16; // hard to jump. | |
| 13562 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 13563 | 3 | else hxofs=-8; | |
| 13564 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 13565 | 3 | else hyofs=-8; | |
| 13566 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 13567 |
1/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 13568 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 13569 | { | ||
| 13570 | ✗ | yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 13571 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 13572 | ✗ | } | |
| 13573 | |||
| 13574 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
3 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; |
| 13575 | |||
| 13576 | |||
| 13577 | 3 | } | |
| 13578 | |||
| 13579 | 348 | bool eBigDig::animate(int32_t index) | |
| 13580 | { | ||
| 13581 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
|
348 | if(switch_hooked) return enemy::animate(index); |
| 13582 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
|
348 | if(dying) |
| 13583 | ✗ | return Dead(index); | |
| 13584 | |||
| 13585 |
2/2✓ Branch 0 taken 296 times.
✓ Branch 1 taken 52 times.
|
348 | if(clk==0) |
| 13586 | { | ||
| 13587 | 52 | removearmos(x,y,ffcactivated); | |
| 13588 | 52 | } | |
| 13589 | |||
| 13590 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
|
348 | switch(misc) |
| 13591 | { | ||
| 13592 | case 0: | ||
| 13593 | 344 | variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23); | |
| 13594 | 344 | break; | |
| 13595 | |||
| 13596 | case 1: | ||
| 13597 | 2 | ++misc; | |
| 13598 | 2 | break; | |
| 13599 | |||
| 13600 | case 2: | ||
| 13601 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | for(int32_t i=0; i<dmisc5; i++) |
| 13602 | { | ||
| 13603 | 1 | addenemy(x,y,dmisc1+0x1000,-15); | |
| 13604 | 1 | } | |
| 13605 | |||
| 13606 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | for(int32_t i=0; i<dmisc6; i++) |
| 13607 | { | ||
| 13608 | 1 | addenemy(x,y,dmisc2+0x1000,-15); | |
| 13609 | 1 | } | |
| 13610 | |||
| 13611 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | for(int32_t i=0; i<dmisc7; i++) |
| 13612 | { | ||
| 13613 | 1 | addenemy(x,y,dmisc3+0x1000,-15); | |
| 13614 | 1 | } | |
| 13615 | |||
| 13616 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | for(int32_t i=0; i<dmisc8; i++) |
| 13617 | { | ||
| 13618 | 1 | addenemy(x,y,dmisc4+0x1000,-15); | |
| 13619 | 1 | } | |
| 13620 | |||
| 13621 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(itemguy) // Hand down the carried item |
| 13622 | { | ||
| 13623 | ✗ | guycarryingitem = guys.Count()-1; | |
| 13624 | ✗ | ((enemy*)guys.spr(guycarryingitem))->itemguy = true; | |
| 13625 | ✗ | itemguy = false; | |
| 13626 | ✗ | } | |
| 13627 | |||
| 13628 | 2 | stop_bgsfx(index); | |
| 13629 | |||
| 13630 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x))); |
| 13631 | |||
| 13632 | 2 | return true; | |
| 13633 | } | ||
| 13634 | |||
| 13635 | 346 | return enemy::animate(index); | |
| 13636 | 348 | } | |
| 13637 | |||
| 13638 | 348 | void eBigDig::draw(BITMAP *dest) | |
| 13639 | { | ||
| 13640 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
|
348 | if(anim!=aDIG) |
| 13641 | { | ||
| 13642 | ✗ | update_enemy_frame(); | |
| 13643 | ✗ | xofs-=8; | |
| 13644 | ✗ | yofs-=8; | |
| 13645 | ✗ | drawblock(dest,15); | |
| 13646 | ✗ | xofs+=8; | |
| 13647 | ✗ | yofs+=8; | |
| 13648 | ✗ | return; | |
| 13649 | } | ||
| 13650 | |||
| 13651 | 348 | tile = o_tile; | |
| 13652 | 348 | int32_t fdiv = frate/4; | |
| 13653 |
1/2✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
|
348 | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; |
| 13654 | |||
| 13655 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
|
348 | int32_t f2=get_qr(qr_NEWENEMYTILES)? |
| 13656 | 348 | efrate:((clk>=(frate>>1))?1:0); | |
| 13657 | |||
| 13658 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
|
348 | if ( do_animation ) |
| 13659 | { | ||
| 13660 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
|
348 | if(get_qr(qr_NEWENEMYTILES)) |
| 13661 | { | ||
| 13662 | ✗ | switch(dir-8) //directions get screwed up after 8. *shrug* | |
| 13663 | { | ||
| 13664 | case up: //u | ||
| 13665 | ✗ | flip=0; | |
| 13666 | ✗ | break; | |
| 13667 | |||
| 13668 | case l_up: //d | ||
| 13669 | ✗ | flip=0; | |
| 13670 | ✗ | tile+=8; | |
| 13671 | ✗ | break; | |
| 13672 | |||
| 13673 | case l_down: //l | ||
| 13674 | ✗ | flip=0; | |
| 13675 | ✗ | tile+=40; | |
| 13676 | ✗ | break; | |
| 13677 | |||
| 13678 | case left: //r | ||
| 13679 | ✗ | flip=0; | |
| 13680 | ✗ | tile+=48; | |
| 13681 | ✗ | break; | |
| 13682 | |||
| 13683 | case r_down: //ul | ||
| 13684 | ✗ | flip=0; | |
| 13685 | ✗ | tile+=80; | |
| 13686 | ✗ | break; | |
| 13687 | |||
| 13688 | case down: //ur | ||
| 13689 | ✗ | flip=0; | |
| 13690 | ✗ | tile+=88; | |
| 13691 | |||
| 13692 | ✗ | break; | |
| 13693 | |||
| 13694 | case r_up: //dl | ||
| 13695 | ✗ | flip=0; | |
| 13696 | ✗ | tile+=120; | |
| 13697 | ✗ | break; | |
| 13698 | |||
| 13699 | case right: //dr | ||
| 13700 | ✗ | flip=0; | |
| 13701 | ✗ | tile+=128; | |
| 13702 | ✗ | break; | |
| 13703 | } | ||
| 13704 | |||
| 13705 | ✗ | tile+=(f2*2); | |
| 13706 | ✗ | } | |
| 13707 | else | ||
| 13708 | { | ||
| 13709 | 348 | tile+=(f2)?0:2; | |
| 13710 | 348 | flip=(clk&1)?1:0; | |
| 13711 | } | ||
| 13712 | 348 | } | |
| 13713 | |||
| 13714 | 348 | xofs-=8; | |
| 13715 | 348 | yofs-=8; | |
| 13716 | 348 | drawblock(dest,15); | |
| 13717 | 348 | xofs+=8; | |
| 13718 | 348 | yofs+=8; | |
| 13719 | 348 | } | |
| 13720 | |||
| 13721 | 2 | int32_t eBigDig::takehit(weapon *w, weapon* realweap) | |
| 13722 | { | ||
| 13723 | 2 | int32_t wpnId = w->id; | |
| 13724 | |||
| 13725 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | if(wpnId==wWhistle && misc==0) |
| 13726 | 2 | misc=1; | |
| 13727 | |||
| 13728 | 2 | return 0; | |
| 13729 | } | ||
| 13730 | |||
| 13731 | /* | ||
| 13732 | eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | ||
| 13733 | { | ||
| 13734 | hxofs=hyofs=8; | ||
| 13735 | hzsz=16; //can't be jumped. | ||
| 13736 | clk2=70; | ||
| 13737 | misc=-1; | ||
| 13738 | mainguy=!getmapflag(); | ||
| 13739 | } | ||
| 13740 | |||
| 13741 | bool eGanon::animate(int32_t index) | ||
| 13742 | { | ||
| 13743 | if(switch_hooked) return enemy::animate(index); | ||
| 13744 | if(dying) | ||
| 13745 | |||
| 13746 | return Dead(index); | ||
| 13747 | |||
| 13748 | if(clk==0) | ||
| 13749 | { | ||
| 13750 | removearmos(x,y,ffcactivated); | ||
| 13751 | } | ||
| 13752 | |||
| 13753 | switch(misc) | ||
| 13754 | { | ||
| 13755 | case -1: | ||
| 13756 | misc=0; | ||
| 13757 | |||
| 13758 | case 0: | ||
| 13759 | if(++clk2>72 && !(zc_oldrand()&3)) | ||
| 13760 | { | ||
| 13761 | addEwpn(x,y,z,wpn,3,wdp,dir,getUID()); | ||
| 13762 | sfx(wpnsfx(wpn),pan(int32_t(x))); | ||
| 13763 | clk2=0; | ||
| 13764 | } | ||
| 13765 | |||
| 13766 | Stunclk=0; | ||
| 13767 | constant_walk(rate,homing,spw_none); | ||
| 13768 | break; | ||
| 13769 | |||
| 13770 | case 1: | ||
| 13771 | case 2: | ||
| 13772 | if(--Stunclk<=0) | ||
| 13773 | { | ||
| 13774 | int32_t r=zc_oldrand(); | ||
| 13775 | |||
| 13776 | if(r&1) | ||
| 13777 | { | ||
| 13778 | y=96; | ||
| 13779 | |||
| 13780 | if(r&2) | ||
| 13781 | x=160; | ||
| 13782 | else | ||
| 13783 | x=48; | ||
| 13784 | |||
| 13785 | if(tooclose(x,y,48)) | ||
| 13786 | x=208-x; | ||
| 13787 | } | ||
| 13788 | |||
| 13789 | //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2 | ||
| 13790 | //{ | ||
| 13791 | // loadpalset(9,pSprite(spBROWN)); //make Ganon visible? | ||
| 13792 | // } | ||
| 13793 | // else | ||
| 13794 | // { | ||
| 13795 | loadpalset(csBOSS,pSprite(d->bosspal)); | ||
| 13796 | // } | ||
| 13797 | misc=0; | ||
| 13798 | } | ||
| 13799 | |||
| 13800 | break; | ||
| 13801 | |||
| 13802 | case 3: | ||
| 13803 | { | ||
| 13804 | if(hclk>0) | ||
| 13805 | break; | ||
| 13806 | |||
| 13807 | misc=4; | ||
| 13808 | clk=0; | ||
| 13809 | hxofs=1000; | ||
| 13810 | loadpalset(9,pSprite(spPILE)); | ||
| 13811 | music_stop(); | ||
| 13812 | stop_sfx(WAV_ROAR); | ||
| 13813 | |||
| 13814 | if(deadsfx>0) sfx(deadsfx,pan(int32_t(x))); | ||
| 13815 | |||
| 13816 | sfx(WAV_GANON); | ||
| 13817 | //Ganon's dustpile; fall in sideview. -Z | ||
| 13818 | item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0); | ||
| 13819 | dustpile->linked_parent = eeGANON; | ||
| 13820 | setmapflag(); | ||
| 13821 | //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0)); | ||
| 13822 | break; | ||
| 13823 | } | ||
| 13824 | |||
| 13825 | case 4: | ||
| 13826 | if(clk>=80) | ||
| 13827 | { | ||
| 13828 | misc=5; | ||
| 13829 | |||
| 13830 | if(getmapflag()) | ||
| 13831 | { | ||
| 13832 | game->lvlitems[dlevel]|=liBOSS; | ||
| 13833 | //play_DmapMusic(); | ||
| 13834 | playLevelMusic(); | ||
| 13835 | return true; | ||
| 13836 | } | ||
| 13837 | |||
| 13838 | sfx(WAV_CLEARED); | ||
| 13839 | items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0)); | ||
| 13840 | setmapflag(); | ||
| 13841 | } | ||
| 13842 | |||
| 13843 | break; | ||
| 13844 | } | ||
| 13845 | |||
| 13846 | //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2 | ||
| 13847 | //{ | ||
| 13848 | //if ( current_item_id(itype_amulet,false) >= 2 ) | ||
| 13849 | //{ | ||
| 13850 | /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible? | ||
| 13851 | //} | ||
| 13852 | //} | ||
| 13853 | |||
| 13854 | |||
| 13855 | return enemy::animate(index); | ||
| 13856 | } | ||
| 13857 | |||
| 13858 | |||
| 13859 | int32_t eGanon::takehit(weapon *w, weapon* realweap) | ||
| 13860 | { | ||
| 13861 | //these are here to bypass compiler warnings about unused arguments | ||
| 13862 | int32_t wpnId = w->id; | ||
| 13863 | int32_t power = w->power; | ||
| 13864 | int32_t enemyHitWeapon = w->parentitem; | ||
| 13865 | |||
| 13866 | switch(misc) | ||
| 13867 | { | ||
| 13868 | case 0: | ||
| 13869 | { | ||
| 13870 | //if we're not using the editor defences, and Ganon isn't hit by a sword, return. | ||
| 13871 | if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14)) | ||
| 13872 | return 0; | ||
| 13873 | |||
| 13874 | //if we are not using the new defences, just reduce his HP | ||
| 13875 | if (!(editorflags & ENEMY_FLAG14)) | ||
| 13876 | { | ||
| 13877 | hp-=power; | ||
| 13878 | if(hp>0) | ||
| 13879 | { | ||
| 13880 | misc=1; | ||
| 13881 | Stunclk=64; | ||
| 13882 | } | ||
| 13883 | else | ||
| 13884 | { | ||
| 13885 | loadpalset(csBOSS,pSprite(spBROWN)); | ||
| 13886 | misc=2; | ||
| 13887 | Stunclk=284; | ||
| 13888 | hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult(); | ||
| 13889 | } | ||
| 13890 | |||
| 13891 | sfx(WAV_EHIT,pan(int32_t(x))); | ||
| 13892 | |||
| 13893 | if(hitsfx>0) sfx(hitsfx,pan(int32_t(x))); | ||
| 13894 | |||
| 13895 | return 1; | ||
| 13896 | } | ||
| 13897 | //otherwise, resolve his defence. | ||
| 13898 | else | ||
| 13899 | { | ||
| 13900 | int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage. | ||
| 13901 | if(hp>0) | ||
| 13902 | { | ||
| 13903 | misc=1; | ||
| 13904 | Stunclk=64; | ||
| 13905 | } | ||
| 13906 | else | ||
| 13907 | { | ||
| 13908 | loadpalset(csBOSS,pSprite(spBROWN)); | ||
| 13909 | misc=2; | ||
| 13910 | Stunclk=284; | ||
| 13911 | hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult(); | ||
| 13912 | } | ||
| 13913 | |||
| 13914 | sfx(WAV_EHIT,pan(int32_t(x))); | ||
| 13915 | |||
| 13916 | if(hitsfx>0) sfx(hitsfx,pan(int32_t(x))); | ||
| 13917 | |||
| 13918 | |||
| 13919 | return 1; | ||
| 13920 | } | ||
| 13921 | } | ||
| 13922 | case 2: | ||
| 13923 | { | ||
| 13924 | if | ||
| 13925 | ( | ||
| 13926 | ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor | ||
| 13927 | || //or nothing specified, use silver arrows+ | ||
| 13928 | ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)) | ||
| 13929 | ) | ||
| 13930 | return 0; | ||
| 13931 | { | ||
| 13932 | misc=3; | ||
| 13933 | hclk=81; | ||
| 13934 | loadpalset(9,pSprite(spBROWN)); | ||
| 13935 | return 1; | ||
| 13936 | } | ||
| 13937 | |||
| 13938 | } | ||
| 13939 | } | ||
| 13940 | |||
| 13941 | return 0; | ||
| 13942 | } | ||
| 13943 | |||
| 13944 | void eGanon::draw(BITMAP *dest) | ||
| 13945 | { | ||
| 13946 | switch(misc) | ||
| 13947 | { | ||
| 13948 | case 0: | ||
| 13949 | if((clk&3)==3) | ||
| 13950 | tile=(zc_oldrand()%5)*2+o_tile; | ||
| 13951 | |||
| 13952 | if(db!=999) | ||
| 13953 | break; | ||
| 13954 | |||
| 13955 | case 2: | ||
| 13956 | if(Stunclk<64 && (Stunclk&1) ) | ||
| 13957 | { | ||
| 13958 | if | ||
| 13959 | ( | ||
| 13960 | ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) ) | ||
| 13961 | || | ||
| 13962 | ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) ) | ||
| 13963 | ) | ||
| 13964 | { | ||
| 13965 | goto ganon_draw; //draw his weapons if we can see him | ||
| 13966 | } | ||
| 13967 | break; | ||
| 13968 | } | ||
| 13969 | |||
| 13970 | case -1: | ||
| 13971 | tile=o_tile; | ||
| 13972 | |||
| 13973 | //fall through | ||
| 13974 | case 1: | ||
| 13975 | case 3: | ||
| 13976 | ganon_draw: | ||
| 13977 | drawblock(dest,15); | ||
| 13978 | break; | ||
| 13979 | |||
| 13980 | case 4: | ||
| 13981 | draw_guts(dest); | ||
| 13982 | draw_flash(dest); | ||
| 13983 | break; | ||
| 13984 | } | ||
| 13985 | |||
| 13986 | if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2 | ||
| 13987 | { | ||
| 13988 | if | ||
| 13989 | ( | ||
| 13990 | ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) ) | ||
| 13991 | || | ||
| 13992 | ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) ) | ||
| 13993 | ) | ||
| 13994 | { | ||
| 13995 | draw_guts(dest); //makes his shots visible, but not him | ||
| 13996 | draw_flash(dest); | ||
| 13997 | } | ||
| 13998 | } | ||
| 13999 | } | ||
| 14000 | |||
| 14001 | void eGanon::draw_guts(BITMAP *dest) | ||
| 14002 | { | ||
| 14003 | int32_t c = zc_min(clk>>3,8); | ||
| 14004 | tile = clk<24 ? 74 : 75; | ||
| 14005 | overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0); | ||
| 14006 | overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0); | ||
| 14007 | overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0); | ||
| 14008 | overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0); | ||
| 14009 | overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0); | ||
| 14010 | overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0); | ||
| 14011 | overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0); | ||
| 14012 | overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0); | ||
| 14013 | } | ||
| 14014 | |||
| 14015 | void eGanon::draw_flash(BITMAP *dest) | ||
| 14016 | { | ||
| 14017 | |||
| 14018 | int32_t c = clk-(clk>>2); | ||
| 14019 | cs = (frame&3)+6; | ||
| 14020 | overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0); | ||
| 14021 | overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2); | ||
| 14022 | overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0); | ||
| 14023 | overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1); | ||
| 14024 | overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0); | ||
| 14025 | overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1); | ||
| 14026 | overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2); | ||
| 14027 | overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3); | ||
| 14028 | } | ||
| 14029 | */ | ||
| 14030 | |||
| 14031 | 2 | eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 14032 | 2 | { | |
| 14033 | 2 | hxofs=hyofs=8; | |
| 14034 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (editorflags & ENEMY_FLAG3) |
| 14035 | { | ||
| 14036 | ✗ | hxofs = 4; | |
| 14037 | ✗ | hyofs = 4; | |
| 14038 | ✗ | hit_width = 24; | |
| 14039 | ✗ | hit_height = 24; | |
| 14040 | ✗ | SIZEflags|=guyflagOVERRIDE_HIT_WIDTH; | |
| 14041 | ✗ | SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT; | |
| 14042 | ✗ | } | |
| 14043 | 2 | hzsz=16; //can't be jumped. | |
| 14044 | 2 | clk2=70; | |
| 14045 | 2 | misc=-1; | |
| 14046 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)); |
| 14047 | 2 | } | |
| 14048 | |||
| 14049 | 945 | bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z | |
| 14050 | { | ||
| 14051 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
|
945 | if(dying) |
| 14052 | |||
| 14053 | ✗ | return Dead(index); | |
| 14054 | |||
| 14055 |
2/2✓ Branch 0 taken 941 times.
✓ Branch 1 taken 4 times.
|
945 | if(clk==0) |
| 14056 | { | ||
| 14057 | 4 | removearmos(x,y,ffcactivated); | |
| 14058 | 4 | } | |
| 14059 | |||
| 14060 |
6/7✓ Branch 0 taken 269 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 511 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 80 times.
✓ Branch 6 taken 1 times.
|
945 | switch(misc) |
| 14061 | { | ||
| 14062 | case -1: | ||
| 14063 | 2 | misc=0; | |
| 14064 | [[fallthrough]]; | ||
| 14065 | case 0: | ||
| 14066 |
4/4✓ Branch 0 taken 31 times.
✓ Branch 1 taken 482 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 8 times.
|
513 | if(++clk2>72 && !(zc_oldrand()&3)) |
| 14067 | { | ||
| 14068 | 8 | addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez); | |
| 14069 | 8 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 14070 | 8 | clk2=0; | |
| 14071 | 8 | } | |
| 14072 | |||
| 14073 | 513 | Stunclk=0; | |
| 14074 | 513 | constant_walk(rate,homing,spw_none); | |
| 14075 | 513 | break; | |
| 14076 | |||
| 14077 | case 1: | ||
| 14078 | case 2: | ||
| 14079 |
2/2✓ Branch 0 taken 266 times.
✓ Branch 1 taken 3 times.
|
269 | if(--Stunclk<=0) |
| 14080 | { | ||
| 14081 | 3 | int32_t r=zc_oldrand(); | |
| 14082 | |||
| 14083 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | if(r&1) |
| 14084 | { | ||
| 14085 | 1 | y=96; | |
| 14086 | |||
| 14087 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(r&2) |
| 14088 | ✗ | x=160; | |
| 14089 | else | ||
| 14090 | 1 | x=48; | |
| 14091 | |||
| 14092 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(tooclose(x,y,48)) |
| 14093 | 1 | x=208-x; | |
| 14094 | 1 | } | |
| 14095 | |||
| 14096 | 3 | loadpalset(csBOSS,pSprite(d->bosspal)); | |
| 14097 | 3 | misc=0; | |
| 14098 | 3 | } | |
| 14099 | |||
| 14100 | 269 | break; | |
| 14101 | |||
| 14102 | case 3: | ||
| 14103 | { | ||
| 14104 |
2/2✓ Branch 0 taken 81 times.
✓ Branch 1 taken 1 times.
|
82 | if(hclk>0) |
| 14105 | 81 | break; | |
| 14106 | |||
| 14107 | 1 | misc=4; | |
| 14108 | 1 | clk=0; | |
| 14109 | 1 | hxofs=1000; | |
| 14110 | 1 | loadpalset(9,pSprite(spPILE)); | |
| 14111 | 1 | music_stop(); | |
| 14112 | 1 | stop_sfx(WAV_ROAR); | |
| 14113 | |||
| 14114 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(deadsfx>0) sfx(deadsfx,pan(int32_t(x))); |
| 14115 | |||
| 14116 | 1 | sfx(WAV_GANON); | |
| 14117 | //Ganon's dustpile; fall in sideview. -Z | ||
| 14118 | //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0); | ||
| 14119 | //dustpile->miscellaneous[31] = eeGANON; | ||
| 14120 |
6/12✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0)); |
| 14121 | 1 | item *dustpile = NULL; | |
| 14122 | //dustpile = (item *)items.spr(items.Count() - 1)->getUID(); | ||
| 14123 | 1 | dustpile = (item *)items.spr(items.Count() - 1); | |
| 14124 | 1 | dustpile->linked_parent = eeGANON; //was miscellaneous[31] | |
| 14125 | //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 ) | ||
| 14126 | //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0)); | ||
| 14127 | 1 | break; | |
| 14128 | } | ||
| 14129 | |||
| 14130 | case 4: | ||
| 14131 |
2/2✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1 times.
|
80 | if(clk>=80) |
| 14132 | { | ||
| 14133 | 1 | misc=5; | |
| 14134 | |||
| 14135 | //game->lvlitems[dlevel]|=liBOSS; | ||
| 14136 | |||
| 14137 | 1 | sfx(WAV_CLEARED); | |
| 14138 | //Add the big TF over the ashes! | ||
| 14139 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for(word q = 0; q < items.Count(); q++) |
| 14140 | { | ||
| 14141 | 2 | item *ashes = (item*)items.spr(q); | |
| 14142 |
3/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
2 | if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY)) |
| 14143 | { | ||
| 14144 | //Z_scripterrlog("Found correct dustpile!\n"); | ||
| 14145 |
4/8✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
1 | items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0)); |
| 14146 | 1 | item *bigtriforce = NULL; | |
| 14147 | 1 | bigtriforce = (item *)items.spr(items.Count() - 1); | |
| 14148 | 1 | bigtriforce->linked_parent = eeGANON; | |
| 14149 | 1 | } | |
| 14150 | 2 | } | |
| 14151 | //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM); | ||
| 14152 | //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z | ||
| 14153 | 1 | } | |
| 14154 | |||
| 14155 | 80 | break; | |
| 14156 | 1 | case 5: return true; | |
| 14157 | } | ||
| 14158 | |||
| 14159 | 944 | return enemy::animate(index); | |
| 14160 | 945 | } | |
| 14161 | |||
| 14162 | |||
| 14163 | 79 | int32_t eGanon::takehit(weapon *w, weapon* realweap) | |
| 14164 | { | ||
| 14165 | //these are here to bypass compiler warnings about unused arguments | ||
| 14166 | 79 | int32_t wpnId = w->id; | |
| 14167 | 79 | int32_t power = w->power; | |
| 14168 | 79 | int32_t enemyHitWeapon = w->parentitem; | |
| 14169 | |||
| 14170 |
3/3✓ Branch 0 taken 54 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 21 times.
|
79 | switch(misc) |
| 14171 | { | ||
| 14172 | case 0: | ||
| 14173 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if(wpnId!=wSword) |
| 14174 | ✗ | return 0; | |
| 14175 | |||
| 14176 | 4 | hp-=power; | |
| 14177 | |||
| 14178 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | if(hp>0) |
| 14179 | { | ||
| 14180 | 3 | misc=1; | |
| 14181 | 3 | Stunclk=64; | |
| 14182 | 3 | } | |
| 14183 | else | ||
| 14184 | { | ||
| 14185 | 1 | loadpalset(csBOSS,pSprite(spBROWN)); | |
| 14186 | 1 | misc=2; | |
| 14187 | 1 | Stunclk=284; | |
| 14188 | 1 | hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult(); | |
| 14189 | } | ||
| 14190 | |||
| 14191 | 4 | sfx(WAV_EHIT,pan(int32_t(x))); | |
| 14192 | |||
| 14193 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if(hitsfx>0) sfx(hitsfx,pan(int32_t(x))); |
| 14194 | |||
| 14195 | 4 | return 1; | |
| 14196 | |||
| 14197 | case 2: | ||
| 14198 |
4/6✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
21 | if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4) |
| 14199 | 20 | return 0; | |
| 14200 | |||
| 14201 | 1 | misc=3; | |
| 14202 | 1 | hclk=81; | |
| 14203 | 1 | loadpalset(9,pSprite(spBROWN)); | |
| 14204 | 1 | return 1; | |
| 14205 | } | ||
| 14206 | |||
| 14207 | 54 | return 0; | |
| 14208 | 79 | } | |
| 14209 | |||
| 14210 | 1333 | void eGanon::draw(BITMAP *dest) | |
| 14211 | { | ||
| 14212 |
6/6✓ Branch 0 taken 274 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 390 times.
✓ Branch 4 taken 511 times.
✓ Branch 5 taken 80 times.
|
1333 | switch(misc) |
| 14213 | { | ||
| 14214 | case 0: | ||
| 14215 |
2/2✓ Branch 0 taken 383 times.
✓ Branch 1 taken 128 times.
|
511 | if((clk&3)==3) |
| 14216 | 128 | tile=(zc_oldrand()%5)*2+o_tile; | |
| 14217 | |||
| 14218 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 511 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
511 | if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet |
| 14219 | { | ||
| 14220 | |||
| 14221 | ✗ | if ( editorflags & ENEMY_FLAG16 ) //draw cloaked | |
| 14222 | { | ||
| 14223 | ✗ | int odraw = drawstyle; | |
| 14224 | ✗ | drawstyle = 2; | |
| 14225 | ✗ | drawblock(dest,15); | |
| 14226 | ✗ | drawstyle = odraw; | |
| 14227 | ✗ | } | |
| 14228 | else | ||
| 14229 | { | ||
| 14230 | ✗ | drawblock(dest,15); | |
| 14231 | } | ||
| 14232 | ✗ | break; | |
| 14233 | |||
| 14234 | } | ||
| 14235 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 511 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
511 | else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) ) |
| 14236 | { | ||
| 14237 | ✗ | if ( editorflags & ENEMY_FLAG16 ) //draw cloaked | |
| 14238 | { | ||
| 14239 | ✗ | int odraw = drawstyle; | |
| 14240 | ✗ | drawstyle = 2; | |
| 14241 | ✗ | drawblock(dest,15); | |
| 14242 | ✗ | drawstyle = odraw; | |
| 14243 | ✗ | } | |
| 14244 | else | ||
| 14245 | { | ||
| 14246 | ✗ | drawblock(dest,15); | |
| 14247 | } | ||
| 14248 | ✗ | break; | |
| 14249 | } | ||
| 14250 |
1/2✓ Branch 0 taken 511 times.
✗ Branch 1 not taken.
|
511 | if(db!=999) |
| 14251 | 511 | break; | |
| 14252 | [[fallthrough]]; | ||
| 14253 | case 2: | ||
| 14254 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
77 | if(Stunclk<64 && (Stunclk&1)) |
| 14255 | ✗ | break; | |
| 14256 | [[fallthrough]]; | ||
| 14257 | case -1: | ||
| 14258 | 467 | tile=o_tile; | |
| 14259 | |||
| 14260 | [[fallthrough]]; | ||
| 14261 | case 1: | ||
| 14262 | case 3: | ||
| 14263 | 741 | drawblock(dest,15); | |
| 14264 | 741 | break; | |
| 14265 | |||
| 14266 | case 4: | ||
| 14267 | 80 | draw_guts(dest); | |
| 14268 | 80 | draw_flash(dest); | |
| 14269 | 80 | break; | |
| 14270 | } | ||
| 14271 | 1333 | } | |
| 14272 | |||
| 14273 | 80 | void eGanon::draw_guts(BITMAP *dest) | |
| 14274 | { | ||
| 14275 |
2/2✓ Branch 0 taken 63 times.
✓ Branch 1 taken 17 times.
|
80 | int32_t c = zc_min(clk>>3,8); |
| 14276 | 80 | tile = clk<24 ? 74 : 75; | |
| 14277 | 80 | overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0); | |
| 14278 | 80 | overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0); | |
| 14279 | 80 | overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0); | |
| 14280 | 80 | overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0); | |
| 14281 | 80 | overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0); | |
| 14282 | 80 | overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0); | |
| 14283 | 80 | overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0); | |
| 14284 | 80 | overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0); | |
| 14285 | 80 | } | |
| 14286 | |||
| 14287 | 80 | void eGanon::draw_flash(BITMAP *dest) | |
| 14288 | { | ||
| 14289 | |||
| 14290 | 80 | int32_t c = clk-(clk>>2); | |
| 14291 | 80 | cs = (frame&3)+6; | |
| 14292 | 80 | overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0); | |
| 14293 | 80 | overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2); | |
| 14294 | 80 | overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0); | |
| 14295 | 80 | overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1); | |
| 14296 | 80 | overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0); | |
| 14297 | 80 | overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1); | |
| 14298 | 80 | overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2); | |
| 14299 | 80 | overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3); | |
| 14300 | 80 | } | |
| 14301 | |||
| 14302 | 2 | void getBigTri(int32_t id2) | |
| 14303 | { | ||
| 14304 | /* | ||
| 14305 | ************************* | ||
| 14306 | * BIG TRIFORCE SEQUENCE * | ||
| 14307 | ************************* | ||
| 14308 | 0 BIGTRI out, WHITE flash in | ||
| 14309 | 4 WHITE flash out, PILE cset white | ||
| 14310 | 8 WHITE in | ||
| 14311 | ... | ||
| 14312 | 188 WHITE out | ||
| 14313 | 191 PILE cset red | ||
| 14314 | 200 top SHUTTER opens | ||
| 14315 | 209 bottom SHUTTER opens | ||
| 14316 | */ | ||
| 14317 | 2 | sfx(itemsbuf[id2].playsound); | |
| 14318 | 2 | guys.clear(); | |
| 14319 | |||
| 14320 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(itemsbuf[id2].flags & ITEM_GAMEDATA) |
| 14321 | { | ||
| 14322 | ✗ | game->lvlitems[dlevel]|=liTRIFORCE; | |
| 14323 | ✗ | } | |
| 14324 | |||
| 14325 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM); |
| 14326 | |||
| 14327 | 2 | draw_screen(tmpscr); | |
| 14328 | |||
| 14329 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 384 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 384 times.
|
386 | for(int32_t f=0; f<24*8 && !Quit; f++) |
| 14330 | { | ||
| 14331 |
2/2✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2 times.
|
384 | if(f==4) |
| 14332 | { | ||
| 14333 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2 times.
|
32 | for(int32_t i=1; i<16; i++) |
| 14334 | { | ||
| 14335 | 30 | RAMpal[CSET(9)+i]=_RGB(63,63,63); | |
| 14336 | 30 | } | |
| 14337 | 2 | } | |
| 14338 | |||
| 14339 |
2/2✓ Branch 0 taken 336 times.
✓ Branch 1 taken 48 times.
|
384 | if((f&7)==0) |
| 14340 | { | ||
| 14341 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 48 times.
|
192 | for(int32_t cs=2; cs<5; cs++) |
| 14342 | { | ||
| 14343 |
2/2✓ Branch 0 taken 2160 times.
✓ Branch 1 taken 144 times.
|
2304 | for(int32_t i=1; i<16; i++) |
| 14344 | { | ||
| 14345 | 2160 | RAMpal[CSET(cs)+i]=_RGB(63,63,63); | |
| 14346 | 2160 | } | |
| 14347 | 144 | } | |
| 14348 | |||
| 14349 | 48 | refreshpal=true; | |
| 14350 | 48 | } | |
| 14351 | |||
| 14352 |
2/2✓ Branch 0 taken 336 times.
✓ Branch 1 taken 48 times.
|
384 | if((f&7)==4) |
| 14353 | { | ||
| 14354 |
1/2✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
|
48 | if(currscr<128) loadlvlpal(DMaps[currdmap].color); |
| 14355 | ✗ | else loadlvlpal(0xB); | |
| 14356 | 48 | } | |
| 14357 | |||
| 14358 |
2/2✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2 times.
|
384 | if(f==191) |
| 14359 | { | ||
| 14360 | 2 | loadpalset(9,pSprite(spPILE)); | |
| 14361 | 2 | } | |
| 14362 | |||
| 14363 | 384 | advanceframe(true); | |
| 14364 | 384 | } | |
| 14365 | |||
| 14366 | //play_DmapMusic(); | ||
| 14367 | 2 | playLevelMusic(); | |
| 14368 | |||
| 14369 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
2 | if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128) |
| 14370 | { | ||
| 14371 | 1 | Hero.dowarp(1,0); //side warp | |
| 14372 | 1 | } | |
| 14373 | 2 | } | |
| 14374 | |||
| 14375 | /**********************************/ | ||
| 14376 | /*** Multiple-Segment Enemies ***/ | ||
| 14377 | /**********************************/ | ||
| 14378 | |||
| 14379 | |||
| 14380 | //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020 | ||
| 14381 | 11 | eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 14382 | 11 | { | |
| 14383 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if( !(editorflags & ENEMY_FLAG5) ) |
| 14384 | { | ||
| 14385 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | x=128; |
| 14386 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | y=48; |
| 14387 | 11 | } | |
| 14388 | //else { x = X; y = Y; } | ||
| 14389 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | dir=(zc_oldrand()&7)+8; |
| 14390 | 11 | superman=1; | |
| 14391 | 11 | fading=fade_invisible; | |
| 14392 | 11 | hxofs=1000; | |
| 14393 | 11 | segcnt=clk; | |
| 14394 | 11 | segid=Id|0x1000; | |
| 14395 | 11 | clk=0; | |
| 14396 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | id=guys.Count(); |
| 14397 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
|
11 | yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); |
| 14398 | 11 | tile=o_tile; | |
| 14399 | 11 | hitdir = -1; | |
| 14400 | 11 | stickclk = 0; | |
| 14401 | |||
| 14402 | /* | ||
| 14403 | if (get_qr(qr_NEWENEMYTILES)) | ||
| 14404 | { | ||
| 14405 | tile=nets+1220; | ||
| 14406 | } | ||
| 14407 | else | ||
| 14408 | { | ||
| 14409 | tile=57; | ||
| 14410 | } | ||
| 14411 | */ | ||
| 14412 | 11 | } | |
| 14413 | |||
| 14414 | 1136 | bool eMoldorm::animate(int32_t index) | |
| 14415 | { | ||
| 14416 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1136 times.
|
1136 | if(switch_hooked) return enemy::animate(index); |
| 14417 | 1136 | int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z | |
| 14418 |
2/2✓ Branch 0 taken 970 times.
✓ Branch 1 taken 166 times.
|
1136 | if ( y > (max_y) ) |
| 14419 | { | ||
| 14420 | 166 | ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019 | |
| 14421 | //Z_scripterrlog("Stickclk is %d\n", stickclk); | ||
| 14422 | 166 | } | |
| 14423 |
2/2✓ Branch 0 taken 1133 times.
✓ Branch 1 taken 3 times.
|
1136 | if ( stickclk > 45 ) |
| 14424 | { | ||
| 14425 | 3 | stickclk = 0; | |
| 14426 | 3 | newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck. | |
| 14427 | 3 | } | |
| 14428 | |||
| 14429 | |||
| 14430 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1136 times.
|
1136 | if(clk==0) |
| 14431 | { | ||
| 14432 | 1136 | removearmos(x,y,ffcactivated); | |
| 14433 | 1136 | } | |
| 14434 | |||
| 14435 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1098 times.
|
1136 | if(clk2) |
| 14436 | { | ||
| 14437 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2 times.
|
38 | if(--clk2 == 0) |
| 14438 | { | ||
| 14439 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(flags&guy_neverret) |
| 14440 | 2 | never_return(index); | |
| 14441 | |||
| 14442 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2 | if(!dmisc2 || (editorflags & ENEMY_FLAG6)) |
| 14443 | 2 | leave_item(); | |
| 14444 | |||
| 14445 | 2 | stop_bgsfx(index); | |
| 14446 | 2 | return true; | |
| 14447 | } | ||
| 14448 | 36 | } | |
| 14449 | else | ||
| 14450 | { | ||
| 14451 |
1/2✓ Branch 0 taken 1098 times.
✗ Branch 1 not taken.
|
1098 | if(stunclk>0) |
| 14452 | ✗ | stunclk=0; | |
| 14453 | 1098 | constant_walk_8_old(rate,homing,spw_floater); | |
| 14454 | |||
| 14455 | |||
| 14456 | 1098 | misc=dir; | |
| 14457 | |||
| 14458 | // If any higher-numbered segments were killed, segcnt can be too high, | ||
| 14459 | // leading to a crash | ||
| 14460 |
1/2✓ Branch 0 taken 1098 times.
✗ Branch 1 not taken.
|
1098 | if(index+segcnt>=guys.Count()) |
| 14461 | ✗ | segcnt=guys.Count()-index-1; | |
| 14462 | |||
| 14463 |
2/2✓ Branch 0 taken 1098 times.
✓ Branch 1 taken 4053 times.
|
5151 | for(int32_t i=index+1; i<index+segcnt+1; i++) |
| 14464 | { | ||
| 14465 | 4053 | enemy* segment=((enemy*)guys.spr(i)); | |
| 14466 | |||
| 14467 | // More validation - if segcnt was wrong, this may not | ||
| 14468 | // actually be a Moldorm segment | ||
| 14469 |
1/2✓ Branch 0 taken 4053 times.
✗ Branch 1 not taken.
|
4053 | if(segment->id!=segid) |
| 14470 | { | ||
| 14471 | ✗ | segcnt=i-index-1; | |
| 14472 | ✗ | break; | |
| 14473 | } | ||
| 14474 | |||
| 14475 |
2/2✓ Branch 0 taken 2952 times.
✓ Branch 1 taken 1101 times.
|
4053 | if(i==index+1) |
| 14476 | { | ||
| 14477 | 1101 | x=segment->x; | |
| 14478 | 1101 | y=segment->y; | |
| 14479 | 1101 | } | |
| 14480 | |||
| 14481 | 4053 | segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z | |
| 14482 | //Script your own blasted segmented bosses!! -Z | ||
| 14483 | 4053 | segment->parent_script_UID = this->script_UID; | |
| 14484 |
4/4✓ Branch 0 taken 1098 times.
✓ Branch 1 taken 2955 times.
✓ Branch 2 taken 146 times.
✓ Branch 3 taken 952 times.
|
4053 | if((i==index+segcnt)&&(i!=index+1)) //tail |
| 14485 | { | ||
| 14486 | 952 | segment->dummy_int[1]=2; | |
| 14487 | 952 | } | |
| 14488 | else | ||
| 14489 | { | ||
| 14490 | 3101 | segment->dummy_int[1]=1; | |
| 14491 | } | ||
| 14492 | |||
| 14493 |
2/2✓ Branch 0 taken 2952 times.
✓ Branch 1 taken 1101 times.
|
4053 | if(i==index+1) //head |
| 14494 | { | ||
| 14495 | 1101 | segment->dummy_int[1]=0; | |
| 14496 | 1101 | } | |
| 14497 | |||
| 14498 |
2/2✓ Branch 0 taken 4043 times.
✓ Branch 1 taken 10 times.
|
4053 | if(segment->hp <= 0) |
| 14499 | { | ||
| 14500 | 10 | int32_t offset=1; | |
| 14501 | |||
| 14502 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 13 times.
|
23 | for(int32_t j=i; j<index+segcnt; j++) |
| 14503 | { | ||
| 14504 | // Triple-check | ||
| 14505 |
1/2✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
|
13 | if(((enemy*)guys.spr(j+1))->id!=segid) |
| 14506 | { | ||
| 14507 | ✗ | segcnt=j-index+1; // Add 1 because of --segcnt below | |
| 14508 | ✗ | break; | |
| 14509 | } | ||
| 14510 | 13 | zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp); | |
| 14511 | 13 | zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk); | |
| 14512 | 13 | } | |
| 14513 | |||
| 14514 | 10 | segment->hclk=33; | |
| 14515 | 10 | --segcnt; | |
| 14516 | 10 | --i; // Recheck the same index in case multiple segments died at once | |
| 14517 | 10 | } | |
| 14518 | 4053 | } | |
| 14519 | |||
| 14520 |
2/2✓ Branch 0 taken 1096 times.
✓ Branch 1 taken 2 times.
|
1098 | if(segcnt==0) |
| 14521 | { | ||
| 14522 | 2 | clk2=19; | |
| 14523 | |||
| 14524 | 2 | x=guys.spr(index+1)->x; | |
| 14525 | 2 | y=guys.spr(index+1)->y; | |
| 14526 | 2 | } | |
| 14527 | } | ||
| 14528 | |||
| 14529 | 1134 | return false; | |
| 14530 | 1136 | } | |
| 14531 | |||
| 14532 | 55 | esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 14533 | 55 | { | |
| 14534 |
1/2✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
55 | if( !(editorflags & ENEMY_FLAG5) ) |
| 14535 | { | ||
| 14536 |
1/2✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
55 | x=128; |
| 14537 |
1/2✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
|
55 | y=48; |
| 14538 | 55 | } | |
| 14539 | |||
| 14540 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
|
55 | yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); |
| 14541 | 55 | hyofs=4; | |
| 14542 | 55 | hit_width=hit_height=8; | |
| 14543 | 55 | hxofs=1000; | |
| 14544 | 55 | mainguy=count_enemy=false; | |
| 14545 | 55 | parentclk = 0; | |
| 14546 | 55 | bgsfx=-1; | |
| 14547 | 55 | flags&=~guy_neverret; | |
| 14548 | //deadsfx = WAV_EDEAD; | ||
| 14549 | 55 | isCore = false; | |
| 14550 | 55 | } | |
| 14551 | |||
| 14552 | 4233 | bool esMoldorm::animate(int32_t index) | |
| 14553 | { | ||
| 14554 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4233 times.
|
4233 | if(switch_hooked) return enemy::animate(index); |
| 14555 | // Shouldn't be possible, but better to be sure | ||
| 14556 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4233 times.
|
4233 | if(index==0) |
| 14557 | ✗ | dying=true; | |
| 14558 | |||
| 14559 |
2/2✓ Branch 0 taken 180 times.
✓ Branch 1 taken 4053 times.
|
4233 | if(dying) |
| 14560 | { | ||
| 14561 |
1/2✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
|
180 | if(!dmisc2) |
| 14562 | 180 | item_set=0; | |
| 14563 | |||
| 14564 | 180 | return Dead(index); | |
| 14565 | } | ||
| 14566 | |||
| 14567 |
2/2✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 2599 times.
|
4053 | if(clk>=0) |
| 14568 | { | ||
| 14569 | 2599 | hxofs=4; | |
| 14570 | 2599 | step=((enemy*)guys.spr(index-1))->step; | |
| 14571 | |||
| 14572 |
2/2✓ Branch 0 taken 183 times.
✓ Branch 1 taken 2416 times.
|
2599 | if(parentclk == 0) |
| 14573 | { | ||
| 14574 | 183 | misc=dir; | |
| 14575 | 183 | dir=((enemy*)guys.spr(index-1))->misc; | |
| 14576 | //do alignment, as in parent's animation :-/ -DD | ||
| 14577 | 183 | x.doFloor(); | |
| 14578 | 183 | y.doFloor(); | |
| 14579 | 183 | } | |
| 14580 | |||
| 14581 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2599 times.
|
2599 | if(step) |
| 14582 | 2599 | parentclk=(parentclk+1)%((int32_t)(8.0/step)); | |
| 14583 | |||
| 14584 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2599 times.
|
2599 | if(!watch) |
| 14585 | { | ||
| 14586 | 2599 | sprite::move(step); | |
| 14587 | 2599 | } | |
| 14588 | 2599 | } | |
| 14589 | |||
| 14590 | 4053 | return enemy::animate(index); | |
| 14591 | 4233 | } | |
| 14592 | |||
| 14593 | 10 | int32_t esMoldorm::takehit(weapon *w, weapon* realweap) | |
| 14594 | { | ||
| 14595 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(enemy::takehit(w,realweap)) |
| 14596 | 10 | return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again | |
| 14597 | |||
| 14598 | ✗ | return 0; | |
| 14599 | 10 | } | |
| 14600 | |||
| 14601 | 4278 | void esMoldorm::draw(BITMAP *dest) | |
| 14602 | { | ||
| 14603 | 4278 | tile=o_tile; | |
| 14604 | 4278 | int32_t fdiv = frate/4; | |
| 14605 |
1/2✓ Branch 0 taken 4278 times.
✗ Branch 1 not taken.
|
4278 | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; |
| 14606 | |||
| 14607 |
2/2✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 2478 times.
|
4278 | int32_t f2=get_qr(qr_NEWENEMYTILES)? |
| 14608 | 4278 | efrate:((clk>=(frate>>1))?1:0); | |
| 14609 | |||
| 14610 |
2/2✓ Branch 0 taken 2478 times.
✓ Branch 1 taken 1800 times.
|
4278 | if(get_qr(qr_NEWENEMYTILES)) |
| 14611 | { | ||
| 14612 | 1800 | tile+=dummy_int[1]*40; | |
| 14613 | |||
| 14614 |
2/2✓ Branch 0 taken 1179 times.
✓ Branch 1 taken 621 times.
|
1800 | if(dir<8) |
| 14615 | { | ||
| 14616 | 1179 | flip=0; | |
| 14617 |
1/2✓ Branch 0 taken 1179 times.
✗ Branch 1 not taken.
|
1179 | tile+=4*zc_max(dir, 0); // dir is -1 if trapped |
| 14618 | |||
| 14619 |
1/2✓ Branch 0 taken 1179 times.
✗ Branch 1 not taken.
|
1179 | if(dir>3) // Skip to the next row for diagonals |
| 14620 | ✗ | tile+=4; | |
| 14621 | 1179 | } | |
| 14622 | else | ||
| 14623 | { | ||
| 14624 |
8/9✓ Branch 0 taken 124 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 92 times.
✓ Branch 5 taken 108 times.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 46 times.
✗ Branch 8 not taken.
|
621 | switch(dir-8) //directions get screwed up after 8. *shrug* |
| 14625 | { | ||
| 14626 | case up: //u | ||
| 14627 | 124 | flip=0; | |
| 14628 | 124 | break; | |
| 14629 | |||
| 14630 | case l_up: //d | ||
| 14631 | 7 | flip=0; | |
| 14632 | 7 | tile+=4; | |
| 14633 | 7 | break; | |
| 14634 | |||
| 14635 | case l_down: //l | ||
| 14636 | 69 | flip=0; | |
| 14637 | 69 | tile+=8; | |
| 14638 | 69 | break; | |
| 14639 | |||
| 14640 | case left: //r | ||
| 14641 | 145 | flip=0; | |
| 14642 | 145 | tile+=12; | |
| 14643 | 145 | break; | |
| 14644 | |||
| 14645 | case r_down: //ul | ||
| 14646 | 92 | flip=0; | |
| 14647 | 92 | tile+=20; | |
| 14648 | 92 | break; | |
| 14649 | |||
| 14650 | case down: //ur | ||
| 14651 | 108 | flip=0; | |
| 14652 | 108 | tile+=24; | |
| 14653 | 108 | break; | |
| 14654 | |||
| 14655 | case r_up: //dl | ||
| 14656 | 30 | flip=0; | |
| 14657 | 30 | tile+=28; | |
| 14658 | 30 | break; | |
| 14659 | |||
| 14660 | case right: //dr | ||
| 14661 | 46 | flip=0; | |
| 14662 | 46 | tile+=32; | |
| 14663 | 46 | break; | |
| 14664 | } | ||
| 14665 | } | ||
| 14666 | |||
| 14667 | 1800 | tile+=f2; | |
| 14668 | 1800 | } | |
| 14669 | |||
| 14670 |
2/2✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 2806 times.
|
4278 | if(clk>=0) |
| 14671 | 2806 | enemy::draw(dest); | |
| 14672 | 4278 | } | |
| 14673 | |||
| 14674 | 8 | eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk) | |
| 14675 | 8 | { | |
| 14676 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if( !(editorflags & ENEMY_FLAG5) ) |
| 14677 | { | ||
| 14678 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | x=64; |
| 14679 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | y=80; |
| 14680 | 8 | } | |
| 14681 | //else { x = X; y = Y; } | ||
| 14682 | //zprint2("lanmola index is %d\n", index); | ||
| 14683 | //byte legaldirs = 0; | ||
| 14684 | 8 | int32_t incr = 16; | |
| 14685 | //int32_t possiiblepos = 0; | ||
| 14686 | //int32_t positions[8] = {0}; | ||
| 14687 | |||
| 14688 | //Don't spawn in pits. | ||
| 14689 |
4/8✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
|
8 | if ( m_walkflag_simple(x, y) ) |
| 14690 | { | ||
| 14691 | //zprint2("Can't spawn here.\n"); | ||
| 14692 | ✗ | for ( ; incr < 240; incr += 16 ) | |
| 14693 | { | ||
| 14694 | //move if we spawn over a pit | ||
| 14695 | //check each direction | ||
| 14696 | ✗ | if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left | |
| 14697 | { | ||
| 14698 | //zprint2("Spawn adjustment: -x (%d)\n", incr); | ||
| 14699 | ✗ | x-=incr; break; | |
| 14700 | } | ||
| 14701 | ✗ | else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right | |
| 14702 | { | ||
| 14703 | //zprint2("Spawn adjustment: +x (%d)\n", incr); | ||
| 14704 | ✗ | x+=incr; break; | |
| 14705 | } | ||
| 14706 | ✗ | else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up | |
| 14707 | { | ||
| 14708 | //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr); | ||
| 14709 | ✗ | x-=incr; y-=incr; break; | |
| 14710 | } | ||
| 14711 | ✗ | else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up | |
| 14712 | { | ||
| 14713 | //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr); | ||
| 14714 | ✗ | x+=incr; y-=incr; break; | |
| 14715 | } | ||
| 14716 | ✗ | else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up | |
| 14717 | { | ||
| 14718 | //zprint2("Spawn adjustment: -y (%d)\n", incr); | ||
| 14719 | ✗ | y -= incr; break; | |
| 14720 | } | ||
| 14721 | ✗ | else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down | |
| 14722 | { | ||
| 14723 | //zprint2("Spawn adjustment: +y (%d)\n", incr); | ||
| 14724 | ✗ | y+=incr; break; | |
| 14725 | } | ||
| 14726 | ✗ | else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down | |
| 14727 | { | ||
| 14728 | //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr); | ||
| 14729 | ✗ | x-=incr; y+=incr; break; | |
| 14730 | } | ||
| 14731 | ✗ | else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down | |
| 14732 | { | ||
| 14733 | //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr); | ||
| 14734 | ✗ | x+=incr; y+=incr; break; | |
| 14735 | } | ||
| 14736 | ✗ | else continue; | |
| 14737 | |||
| 14738 | } | ||
| 14739 | |||
| 14740 | ✗ | } | |
| 14741 | |||
| 14742 | 8 | dir=up; | |
| 14743 | 8 | superman=1; | |
| 14744 | 8 | fading=fade_invisible; | |
| 14745 | 8 | hxofs=1000; | |
| 14746 | 8 | segcnt=clk; | |
| 14747 | 8 | clk=0; | |
| 14748 | //set up move history | ||
| 14749 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 72 times.
|
80 | for(int32_t i=0; i <= (1<<dmisc2); i++) |
| 14750 |
3/6✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
|
72 | prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir)); |
| 14751 | 8 | } | |
| 14752 | |||
| 14753 | 2651 | bool eLanmola::animate(int32_t index) | |
| 14754 | { | ||
| 14755 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
|
2651 | if(switch_hooked) return enemy::animate(index); |
| 14756 |
2/2✓ Branch 0 taken 2302 times.
✓ Branch 1 taken 349 times.
|
2651 | if(clk==0) |
| 14757 | { | ||
| 14758 | 349 | removearmos(x,y,ffcactivated); | |
| 14759 | 349 | } | |
| 14760 | |||
| 14761 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2613 times.
|
2651 | if(clk2) |
| 14762 | { | ||
| 14763 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2 times.
|
38 | if(--clk2 == 0) |
| 14764 | { | ||
| 14765 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item. |
| 14766 | 2 | leave_item(); | |
| 14767 | |||
| 14768 | 2 | stop_bgsfx(index); | |
| 14769 | 2 | return true; | |
| 14770 | } | ||
| 14771 | |||
| 14772 | 36 | return false; | |
| 14773 | } | ||
| 14774 | |||
| 14775 | |||
| 14776 | //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes | ||
| 14777 | //the direction AND x,y position of the lanmola to vary in uncertain ways. | ||
| 14778 | //I've added a complete movement history to this enemy to compensate -DD | ||
| 14779 | 2613 | constant_walk(rate,homing,spw_none); | |
| 14780 | 2613 | prevState.pop_front(); | |
| 14781 | 2613 | prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir)); | |
| 14782 | |||
| 14783 | // This could cause a crash with Moldorms. I didn't see the same problem | ||
| 14784 | // with Lanmolas, but it looks like it ought to be possible, so here's | ||
| 14785 | // the same solution. - Saf | ||
| 14786 |
1/2✓ Branch 0 taken 2613 times.
✗ Branch 1 not taken.
|
2613 | if(index+segcnt>=guys.Count()) |
| 14787 | ✗ | segcnt=guys.Count()-index-1; | |
| 14788 | |||
| 14789 |
2/2✓ Branch 0 taken 2613 times.
✓ Branch 1 taken 9754 times.
|
12367 | for(int32_t i=index+1; i<index+segcnt+1; i++) |
| 14790 | { | ||
| 14791 | 9754 | enemy* segment=((enemy*)guys.spr(i)); | |
| 14792 | |||
| 14793 | // More validation in case segcnt is wrong | ||
| 14794 |
1/2✓ Branch 0 taken 9754 times.
✗ Branch 1 not taken.
|
9754 | if((segment->id&0xFFF)!=(id&0xFFF)) |
| 14795 | { | ||
| 14796 | ✗ | segcnt=i-index-1; | |
| 14797 | ✗ | break; | |
| 14798 | } | ||
| 14799 | |||
| 14800 | 9754 | segment->o_tile=o_tile; | |
| 14801 | 9754 | segment->parent_script_UID = this->script_UID; | |
| 14802 |
4/4✓ Branch 0 taken 2613 times.
✓ Branch 1 taken 7141 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 2116 times.
|
9754 | if((i==index+segcnt)&&(i!=index+1)) |
| 14803 | { | ||
| 14804 | 2116 | segment->dummy_int[1]=1; //tail | |
| 14805 | 2116 | } | |
| 14806 | else | ||
| 14807 | { | ||
| 14808 | 7638 | segment->dummy_int[1]=0; | |
| 14809 | } | ||
| 14810 | |||
| 14811 |
2/2✓ Branch 0 taken 9731 times.
✓ Branch 1 taken 23 times.
|
9754 | if(segment->hp <= 0) |
| 14812 | { | ||
| 14813 |
2/2✓ Branch 0 taken 23 times.
✓ Branch 1 taken 31 times.
|
54 | for(int32_t j=i; j<index+segcnt; j++) |
| 14814 | { | ||
| 14815 | // Triple-check | ||
| 14816 |
1/2✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
|
31 | if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF)) |
| 14817 | { | ||
| 14818 | ✗ | segcnt=j-index+1; // Add 1 because of --segcnt below | |
| 14819 | ✗ | break; | |
| 14820 | } | ||
| 14821 | 31 | zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp); | |
| 14822 | 31 | zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk); | |
| 14823 | 31 | } | |
| 14824 | |||
| 14825 | 23 | ((enemy*)guys.spr(i))->hclk=33; | |
| 14826 | 23 | --segcnt; | |
| 14827 | 23 | --i; // Recheck the same index in case multiple segments died at once | |
| 14828 | 23 | } | |
| 14829 | 9754 | } | |
| 14830 | |||
| 14831 |
2/2✓ Branch 0 taken 2611 times.
✓ Branch 1 taken 2 times.
|
2613 | if(segcnt==0) |
| 14832 | { | ||
| 14833 | 2 | clk2=19; | |
| 14834 | 2 | x=guys.spr(index+1)->x; | |
| 14835 | 2 | y=guys.spr(index+1)->y; | |
| 14836 | 2 | setmapflag(mTMPNORET); | |
| 14837 | 2 | } | |
| 14838 | |||
| 14839 | //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative. | ||
| 14840 | //which is... disastrous. | ||
| 14841 | 2613 | hp = 1; | |
| 14842 | 2613 | return enemy::animate(index); | |
| 14843 | 2651 | } | |
| 14844 | |||
| 14845 | 44 | esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk) | |
| 14846 | 44 | { | |
| 14847 |
1/2✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
|
44 | if( !(editorflags & ENEMY_FLAG5) ) |
| 14848 | { | ||
| 14849 |
1/2✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
|
44 | x=64; |
| 14850 |
1/2✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
|
44 | y=80; |
| 14851 | 44 | } | |
| 14852 | 44 | int32_t incr = 16; | |
| 14853 | //Don't spawn in pits. | ||
| 14854 |
4/8✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
|
44 | if ( m_walkflag_simple(x, y) ) |
| 14855 | { | ||
| 14856 | //zprint2("Can't spawn here.\n"); | ||
| 14857 | ✗ | for ( ; incr < 240; incr += 16 ) | |
| 14858 | { | ||
| 14859 | //move if we spawn over a pit | ||
| 14860 | //check each direction | ||
| 14861 | ✗ | if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left | |
| 14862 | { | ||
| 14863 | //zprint2("Spawn adjustment: -x (%d)\n", incr); | ||
| 14864 | ✗ | x-=incr; break; | |
| 14865 | } | ||
| 14866 | ✗ | else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right | |
| 14867 | { | ||
| 14868 | //zprint2("Spawn adjustment: +x (%d)\n", incr); | ||
| 14869 | ✗ | x+=incr; break; | |
| 14870 | } | ||
| 14871 | ✗ | else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up | |
| 14872 | { | ||
| 14873 | //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr); | ||
| 14874 | ✗ | x-=incr; y-=incr; break; | |
| 14875 | } | ||
| 14876 | ✗ | else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up | |
| 14877 | { | ||
| 14878 | //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr); | ||
| 14879 | ✗ | x+=incr; y-=incr; break; | |
| 14880 | } | ||
| 14881 | ✗ | else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up | |
| 14882 | { | ||
| 14883 | //zprint2("Spawn adjustment: -y (%d)\n", incr); | ||
| 14884 | ✗ | y -= incr; break; | |
| 14885 | } | ||
| 14886 | ✗ | else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down | |
| 14887 | { | ||
| 14888 | //zprint2("Spawn adjustment: +y (%d)\n", incr); | ||
| 14889 | ✗ | y+=incr; break; | |
| 14890 | } | ||
| 14891 | ✗ | else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down | |
| 14892 | { | ||
| 14893 | //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr); | ||
| 14894 | ✗ | x-=incr; y+=incr; break; | |
| 14895 | } | ||
| 14896 | ✗ | else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down | |
| 14897 | { | ||
| 14898 | //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr); | ||
| 14899 | ✗ | x+=incr; y+=incr; break; | |
| 14900 | } | ||
| 14901 | ✗ | else continue; | |
| 14902 | |||
| 14903 | } | ||
| 14904 | |||
| 14905 | ✗ | } | |
| 14906 | |||
| 14907 | 44 | hxofs=1000; | |
| 14908 | 44 | hit_width=8; | |
| 14909 | 44 | mainguy=false; | |
| 14910 | 44 | count_enemy=(id<0x2000)?true:false; | |
| 14911 | |||
| 14912 | //set up move history | ||
| 14913 |
2/2✓ Branch 0 taken 44 times.
✓ Branch 1 taken 396 times.
|
440 | for(int32_t i=0; i <= (1<<dmisc2); i++) |
| 14914 |
3/6✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 396 times.
✗ Branch 5 not taken.
|
396 | prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir)); |
| 14915 | |||
| 14916 | 44 | bgsfx = -1; | |
| 14917 | 44 | isCore = false; | |
| 14918 | 44 | flags&=~guy_neverret; | |
| 14919 | 44 | } | |
| 14920 | |||
| 14921 | 10148 | bool esLanmola::animate(int32_t index) | |
| 14922 | { | ||
| 14923 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10148 times.
|
10148 | if(switch_hooked) return enemy::animate(index); |
| 14924 | // Shouldn't be possible, but who knows | ||
| 14925 |
1/2✓ Branch 0 taken 10148 times.
✗ Branch 1 not taken.
|
10148 | if(index==0) |
| 14926 | ✗ | dying=true; | |
| 14927 | |||
| 14928 |
2/2✓ Branch 0 taken 394 times.
✓ Branch 1 taken 9754 times.
|
10148 | if(dying) |
| 14929 | { | ||
| 14930 | 394 | xofs=0; | |
| 14931 | |||
| 14932 |
2/2✓ Branch 0 taken 214 times.
✓ Branch 1 taken 180 times.
|
394 | if(!dmisc3) |
| 14933 | 180 | item_set=0; | |
| 14934 | |||
| 14935 | 394 | return Dead(index); | |
| 14936 | } | ||
| 14937 | |||
| 14938 |
2/2✓ Branch 0 taken 816 times.
✓ Branch 1 taken 8938 times.
|
9754 | if(clk>=0) |
| 14939 | { | ||
| 14940 | 8938 | hxofs=4; | |
| 14941 | |||
| 14942 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8938 times.
|
8938 | if(!watch) |
| 14943 | { | ||
| 14944 | 8938 | std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front(); | |
| 14945 | 8938 | prevState.pop_front(); | |
| 14946 | 8938 | prevState.push_back(newstate); | |
| 14947 | 8938 | x = newstate.first.first; | |
| 14948 | 8938 | y = newstate.first.second; | |
| 14949 | 8938 | dir = newstate.second; | |
| 14950 | 8938 | } | |
| 14951 | 8938 | } | |
| 14952 | |||
| 14953 | 9754 | return enemy::animate(index); | |
| 14954 | 10148 | } | |
| 14955 | |||
| 14956 | 27 | int32_t esLanmola::takehit(weapon *w, weapon* realweap) | |
| 14957 | { | ||
| 14958 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | if(enemy::takehit(w,realweap)) |
| 14959 | 27 | return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again | |
| 14960 | |||
| 14961 | ✗ | return 0; | |
| 14962 | 27 | } | |
| 14963 | |||
| 14964 | 10157 | void esLanmola::draw(BITMAP *dest) | |
| 14965 | { | ||
| 14966 | 10157 | tile=o_tile; | |
| 14967 | 10157 | int32_t fdiv = frate/4; | |
| 14968 |
1/2✓ Branch 0 taken 10157 times.
✗ Branch 1 not taken.
|
10157 | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; |
| 14969 | |||
| 14970 |
2/2✓ Branch 0 taken 5125 times.
✓ Branch 1 taken 5032 times.
|
10157 | int32_t f2=get_qr(qr_NEWENEMYTILES)? |
| 14971 | 10157 | efrate:((clk>=(frate>>1))?1:0); | |
| 14972 | |||
| 14973 |
2/2✓ Branch 0 taken 5125 times.
✓ Branch 1 taken 5032 times.
|
10157 | if(get_qr(qr_NEWENEMYTILES)) |
| 14974 | { | ||
| 14975 |
2/2✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 3981 times.
|
5125 | if(id>=0x2000) |
| 14976 | { | ||
| 14977 | 3981 | tile+=20; | |
| 14978 | |||
| 14979 |
2/2✓ Branch 0 taken 2756 times.
✓ Branch 1 taken 1225 times.
|
3981 | if(dummy_int[1]==1) |
| 14980 | { | ||
| 14981 | 1225 | tile+=20; | |
| 14982 | 1225 | } | |
| 14983 | 3981 | } | |
| 14984 | |||
| 14985 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 1542 times.
✓ Branch 2 taken 967 times.
✓ Branch 3 taken 1298 times.
✓ Branch 4 taken 1318 times.
|
5125 | switch(dir) |
| 14986 | { | ||
| 14987 | case up: | ||
| 14988 | 1542 | flip=0; | |
| 14989 | 1542 | break; | |
| 14990 | |||
| 14991 | case down: | ||
| 14992 | 967 | flip=0; | |
| 14993 | 967 | tile+=4; | |
| 14994 | 967 | break; | |
| 14995 | |||
| 14996 | case left: | ||
| 14997 | 1298 | flip=0; | |
| 14998 | 1298 | tile+=8; | |
| 14999 | 1298 | break; | |
| 15000 | |||
| 15001 | case right: | ||
| 15002 | 1318 | flip=0; | |
| 15003 | 1318 | tile+=12; | |
| 15004 | 1318 | break; | |
| 15005 | } | ||
| 15006 | |||
| 15007 | 5125 | tile+=f2; | |
| 15008 | 5125 | } | |
| 15009 | else | ||
| 15010 | { | ||
| 15011 |
2/2✓ Branch 0 taken 1509 times.
✓ Branch 1 taken 3523 times.
|
5032 | if(id>=0x2000) |
| 15012 | { | ||
| 15013 | 3523 | tile+=1; | |
| 15014 | 3523 | } | |
| 15015 | } | ||
| 15016 | |||
| 15017 |
2/2✓ Branch 0 taken 816 times.
✓ Branch 1 taken 9341 times.
|
10157 | if(clk>=0) |
| 15018 | 9341 | enemy::draw(dest); | |
| 15019 | 10157 | } | |
| 15020 | |||
| 15021 | 5 | eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0) | |
| 15022 | 5 | { | |
| 15023 | //these are here to bypass compiler warnings about unused arguments | ||
| 15024 | 5 | Clk=Clk; | |
| 15025 | 5 | superman=1; | |
| 15026 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | dir=(zc_oldrand()&7)+8; |
| 15027 | 5 | armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8); | |
| 15028 | |||
| 15029 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5 times.
|
25 | for(int32_t i=0; i<armcnt; i++) |
| 15030 | 20 | arm[i]=i; | |
| 15031 | |||
| 15032 | 5 | fading=fade_blue_poof; | |
| 15033 | //nets+4680; | ||
| 15034 | 5 | adjusted=false; | |
| 15035 | 5 | SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020 | |
| 15036 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
5 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 15037 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 15038 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 15039 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
5 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 15040 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 15041 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 15042 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 15043 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 15044 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 15045 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 15046 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 15047 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 15048 | { | ||
| 15049 | ✗ | yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); | |
| 15050 | ✗ | } | |
| 15051 | |||
| 15052 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; |
| 15053 | 5 | } | |
| 15054 | |||
| 15055 | 1630 | bool eManhandla::animate(int32_t index) | |
| 15056 | { | ||
| 15057 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1630 times.
|
1630 | if(switch_hooked) return enemy::animate(index); |
| 15058 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 1594 times.
|
1630 | if(dying) |
| 15059 | 36 | return Dead(index); | |
| 15060 | |||
| 15061 |
2/2✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8 times.
|
1594 | if(clk==0) |
| 15062 | { | ||
| 15063 | 8 | removearmos(x,y,ffcactivated); | |
| 15064 | 8 | } | |
| 15065 | |||
| 15066 | |||
| 15067 | // check arm status, move dead ones to end of group | ||
| 15068 |
2/2✓ Branch 0 taken 5094 times.
✓ Branch 1 taken 1594 times.
|
6688 | for(int32_t i=0; i<armcnt; i++) |
| 15069 | { | ||
| 15070 | 5094 | enemy* cur_arm = ((enemy*)guys.spr(index+i+1)); | |
| 15071 |
3/4✓ Branch 0 taken 5094 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 5086 times.
|
5094 | if(!cur_arm || cur_arm->dying) |
| 15072 | { | ||
| 15073 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
|
17 | for(int32_t j=i; j<armcnt-1; j++) |
| 15074 | { | ||
| 15075 | 9 | zc_swap(arm[j],arm[j+1]); | |
| 15076 | 9 | guys.swap(index+j+1,index+j+2); | |
| 15077 | 9 | } | |
| 15078 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10 |
| 15079 | { | ||
| 15080 | ✗ | leave_item(); | |
| 15081 | ✗ | } | |
| 15082 | 8 | --armcnt; | |
| 15083 | 8 | --i; | |
| 15084 | 8 | continue; | |
| 15085 | } | ||
| 15086 |
2/2✓ Branch 0 taken 5066 times.
✓ Branch 1 taken 20 times.
|
5086 | if(!adjusted) |
| 15087 | { | ||
| 15088 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | if(!dmisc2) |
| 15089 | { | ||
| 15090 | 20 | cur_arm->o_tile=o_tile+40; | |
| 15091 | 20 | cur_arm->parent_script_UID = this->script_UID; | |
| 15092 | 20 | } | |
| 15093 | else | ||
| 15094 | { | ||
| 15095 | ✗ | cur_arm->o_tile=o_tile+160; | |
| 15096 | ✗ | cur_arm->parent_script_UID = this->script_UID; | |
| 15097 | } | ||
| 15098 | 20 | } | |
| 15099 | 5086 | } | |
| 15100 | |||
| 15101 | 1594 | adjusted=true; | |
| 15102 | |||
| 15103 | // move or die | ||
| 15104 |
2/2✓ Branch 0 taken 1592 times.
✓ Branch 1 taken 2 times.
|
1594 | if(armcnt==0) |
| 15105 | 2 | hp=0; | |
| 15106 | else | ||
| 15107 | { | ||
| 15108 | // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5. | ||
| 15109 |
1/2✓ Branch 0 taken 1592 times.
✗ Branch 1 not taken.
|
1592 | step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100); |
| 15110 |
1/2✓ Branch 0 taken 1592 times.
✗ Branch 1 not taken.
|
1592 | if (step > 4.5_zf) step = 4.5_zf; |
| 15111 | 1592 | int32_t dx1=0, dy1=-8, dx2=15, dy2=15; | |
| 15112 | |||
| 15113 |
1/2✓ Branch 0 taken 1592 times.
✗ Branch 1 not taken.
|
1592 | if(!dmisc2) |
| 15114 | { | ||
| 15115 |
2/2✓ Branch 0 taken 5086 times.
✓ Branch 1 taken 1592 times.
|
6678 | for(int32_t i=0; i<armcnt; i++) |
| 15116 | { | ||
| 15117 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 995 times.
✓ Branch 2 taken 1505 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1562 times.
|
5086 | switch(arm[i]) |
| 15118 | { | ||
| 15119 | case 0: | ||
| 15120 | 995 | dy1=-24; | |
| 15121 | 995 | break; | |
| 15122 | |||
| 15123 | case 1: | ||
| 15124 | 1505 | dy2=31; | |
| 15125 | 1505 | break; | |
| 15126 | |||
| 15127 | case 2: | ||
| 15128 | 1024 | dx1=-16; | |
| 15129 | 1024 | break; | |
| 15130 | |||
| 15131 | case 3: | ||
| 15132 | 1562 | dx2=31; | |
| 15133 | 1562 | break; | |
| 15134 | } | ||
| 15135 | 5086 | } | |
| 15136 | 1592 | } | |
| 15137 | else | ||
| 15138 | { | ||
| 15139 | ✗ | dx1=-8, dy1=-16, dx2=23, dy2=23; | |
| 15140 | |||
| 15141 | ✗ | for(int32_t i=0; i<armcnt; i++) | |
| 15142 | { | ||
| 15143 | ✗ | switch(arm[i]&3) | |
| 15144 | { | ||
| 15145 | case 0: | ||
| 15146 | ✗ | dy1=-32; | |
| 15147 | ✗ | break; | |
| 15148 | |||
| 15149 | case 1: | ||
| 15150 | ✗ | dy2=39; | |
| 15151 | ✗ | break; | |
| 15152 | |||
| 15153 | case 2: | ||
| 15154 | ✗ | dx1=-24; | |
| 15155 | ✗ | break; | |
| 15156 | |||
| 15157 | case 3: | ||
| 15158 | ✗ | dx2=39; | |
| 15159 | ✗ | break; | |
| 15160 | } | ||
| 15161 | ✗ | } | |
| 15162 | } | ||
| 15163 | |||
| 15164 | 1592 | variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2); | |
| 15165 | |||
| 15166 |
2/2✓ Branch 0 taken 5086 times.
✓ Branch 1 taken 1592 times.
|
6678 | for(int32_t i=0; i<armcnt; i++) |
| 15167 | { | ||
| 15168 | 5086 | zfix dx=(zfix)0,dy=(zfix)0; | |
| 15169 | |||
| 15170 |
1/2✓ Branch 0 taken 5086 times.
✗ Branch 1 not taken.
|
5086 | if(!dmisc2) |
| 15171 | { | ||
| 15172 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 995 times.
✓ Branch 2 taken 1505 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1562 times.
|
5086 | switch(arm[i]) |
| 15173 | { | ||
| 15174 | case 0: | ||
| 15175 | 995 | dy=-16; | |
| 15176 | 995 | break; | |
| 15177 | |||
| 15178 | case 1: | ||
| 15179 | 1505 | dy=16; | |
| 15180 | 1505 | break; | |
| 15181 | |||
| 15182 | case 2: | ||
| 15183 | 1024 | dx=-16; | |
| 15184 | 1024 | break; | |
| 15185 | |||
| 15186 | case 3: | ||
| 15187 | 1562 | dx=16; | |
| 15188 | 1562 | break; | |
| 15189 | } | ||
| 15190 | 5086 | } | |
| 15191 | else | ||
| 15192 | { | ||
| 15193 | ✗ | switch(arm[i]) | |
| 15194 | { | ||
| 15195 | case 0: | ||
| 15196 | ✗ | dy=-24; | |
| 15197 | ✗ | dx=-8; | |
| 15198 | ✗ | break; | |
| 15199 | |||
| 15200 | case 1: | ||
| 15201 | ✗ | dy=24; | |
| 15202 | ✗ | dx=8; | |
| 15203 | ✗ | break; | |
| 15204 | |||
| 15205 | case 2: | ||
| 15206 | ✗ | dx=-24; | |
| 15207 | ✗ | dy=8; | |
| 15208 | ✗ | break; | |
| 15209 | |||
| 15210 | case 3: | ||
| 15211 | ✗ | dx=24; | |
| 15212 | ✗ | dy=-8; | |
| 15213 | ✗ | break; | |
| 15214 | |||
| 15215 | case 4: | ||
| 15216 | ✗ | dy=-24; | |
| 15217 | ✗ | dx=8; | |
| 15218 | ✗ | break; | |
| 15219 | |||
| 15220 | case 5: | ||
| 15221 | ✗ | dy=24; | |
| 15222 | ✗ | dx=-8; | |
| 15223 | ✗ | break; | |
| 15224 | |||
| 15225 | case 6: | ||
| 15226 | ✗ | dx=-24; | |
| 15227 | ✗ | dy=-8; | |
| 15228 | ✗ | break; | |
| 15229 | |||
| 15230 | case 7: | ||
| 15231 | ✗ | dx=24; | |
| 15232 | ✗ | dy=8; | |
| 15233 | ✗ | break; | |
| 15234 | } | ||
| 15235 | } | ||
| 15236 | |||
| 15237 | 5086 | guys.spr(index+i+1)->x = x+dx; | |
| 15238 | 5086 | guys.spr(index+i+1)->y = y+dy; | |
| 15239 | 5086 | } | |
| 15240 | } | ||
| 15241 | |||
| 15242 | 1594 | return enemy::animate(index); | |
| 15243 | 1630 | } | |
| 15244 | |||
| 15245 | |||
| 15246 | 20 | int32_t eManhandla::takehit(weapon *w, weapon* realweap) | |
| 15247 | { | ||
| 15248 | 20 | int32_t wpnId = w->id; | |
| 15249 | |||
| 15250 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
|
20 | if(dying) |
| 15251 | ✗ | return 0; | |
| 15252 | |||
| 15253 |
2/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | switch(wpnId) |
| 15254 | { | ||
| 15255 | case wBomb: | ||
| 15256 | case wSBomb: | ||
| 15257 | case wSword: | ||
| 15258 | case wHammer: | ||
| 15259 | case wWand: | ||
| 15260 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
15 | if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x))); |
| 15261 | |||
| 15262 | case wLitBomb: | ||
| 15263 | case wLitSBomb: | ||
| 15264 | case wBait: | ||
| 15265 | case wWhistle: | ||
| 15266 | case wFire: | ||
| 15267 | case wWind: | ||
| 15268 | case wSSparkle: | ||
| 15269 | case wFSparkle: | ||
| 15270 | case wPhantom: | ||
| 15271 | 20 | return 0; | |
| 15272 | |||
| 15273 | case wHookshot: | ||
| 15274 | case wBrang: | ||
| 15275 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 15276 | ✗ | break; | |
| 15277 | |||
| 15278 | default: | ||
| 15279 | ✗ | if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x))); | |
| 15280 | ✗ | else sfx(WAV_CHINK,pan(int32_t(x))); | |
| 15281 | |||
| 15282 | ✗ | } | |
| 15283 | |||
| 15284 | ✗ | return 1; | |
| 15285 | 20 | } | |
| 15286 | |||
| 15287 | 1628 | void eManhandla::draw(BITMAP *dest) | |
| 15288 | { | ||
| 15289 | 1628 | tile=o_tile; | |
| 15290 | 1628 | int32_t fdiv = frate/4; | |
| 15291 |
1/2✓ Branch 0 taken 1628 times.
✗ Branch 1 not taken.
|
1628 | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; |
| 15292 | |||
| 15293 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1628 times.
|
1628 | int32_t f2=get_qr(qr_NEWENEMYTILES)? |
| 15294 | 1628 | efrate:((clk>=(frate>>1))?1:0); | |
| 15295 | |||
| 15296 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1628 times.
|
1628 | if(get_qr(qr_NEWENEMYTILES)) |
| 15297 | { | ||
| 15298 | ✗ | if(!dmisc2) | |
| 15299 | { | ||
| 15300 | ✗ | switch(dir-8) //directions get screwed up after 8. *shrug* | |
| 15301 | { | ||
| 15302 | case up: //u | ||
| 15303 | ✗ | flip=0; | |
| 15304 | ✗ | break; | |
| 15305 | |||
| 15306 | case l_up: //d | ||
| 15307 | ✗ | flip=0; | |
| 15308 | ✗ | tile+=4; | |
| 15309 | ✗ | break; | |
| 15310 | |||
| 15311 | case l_down: //l | ||
| 15312 | ✗ | flip=0; | |
| 15313 | ✗ | tile+=8; | |
| 15314 | ✗ | break; | |
| 15315 | |||
| 15316 | case left: //r | ||
| 15317 | ✗ | flip=0; | |
| 15318 | ✗ | tile+=12; | |
| 15319 | ✗ | break; | |
| 15320 | |||
| 15321 | case r_down: //ul | ||
| 15322 | ✗ | flip=0; | |
| 15323 | ✗ | tile+=20; | |
| 15324 | ✗ | break; | |
| 15325 | |||
| 15326 | case down: //ur | ||
| 15327 | ✗ | flip=0; | |
| 15328 | ✗ | tile+=24; | |
| 15329 | ✗ | break; | |
| 15330 | |||
| 15331 | case r_up: //dl | ||
| 15332 | ✗ | flip=0; | |
| 15333 | ✗ | tile+=28; | |
| 15334 | ✗ | break; | |
| 15335 | |||
| 15336 | case right: //dr | ||
| 15337 | ✗ | flip=0; | |
| 15338 | ✗ | tile+=32; | |
| 15339 | ✗ | break; | |
| 15340 | } | ||
| 15341 | |||
| 15342 | ✗ | tile+=f2; | |
| 15343 | ✗ | enemy::draw(dest); | |
| 15344 | ✗ | } //manhandla 2, big body | |
| 15345 | else | ||
| 15346 | { | ||
| 15347 | |||
| 15348 | ✗ | switch(dir-8) //directions get screwed up after 8. *shrug* | |
| 15349 | { | ||
| 15350 | case up: //u | ||
| 15351 | ✗ | flip=0; | |
| 15352 | ✗ | break; | |
| 15353 | |||
| 15354 | case l_up: //d | ||
| 15355 | ✗ | flip=0; | |
| 15356 | ✗ | tile+=8; | |
| 15357 | ✗ | break; | |
| 15358 | |||
| 15359 | case l_down: //l | ||
| 15360 | ✗ | flip=0; | |
| 15361 | ✗ | tile+=40; | |
| 15362 | ✗ | break; | |
| 15363 | |||
| 15364 | case left: //r | ||
| 15365 | ✗ | flip=0; | |
| 15366 | ✗ | tile+=48; | |
| 15367 | ✗ | break; | |
| 15368 | |||
| 15369 | case r_down: //ul | ||
| 15370 | ✗ | flip=0; | |
| 15371 | ✗ | tile+=80; | |
| 15372 | ✗ | break; | |
| 15373 | |||
| 15374 | case down: //ur | ||
| 15375 | ✗ | flip=0; | |
| 15376 | ✗ | tile+=88; | |
| 15377 | ✗ | break; | |
| 15378 | |||
| 15379 | case r_up: //dl | ||
| 15380 | ✗ | flip=0; | |
| 15381 | ✗ | tile+=120; | |
| 15382 | ✗ | break; | |
| 15383 | |||
| 15384 | case right: //dr | ||
| 15385 | ✗ | flip=0; | |
| 15386 | ✗ | tile+=128; | |
| 15387 | ✗ | break; | |
| 15388 | } | ||
| 15389 | |||
| 15390 | ✗ | tile+=(f2*2); | |
| 15391 | ✗ | xofs-=8; | |
| 15392 | ✗ | yofs-=8; | |
| 15393 | ✗ | drawblock(dest,15); | |
| 15394 | ✗ | xofs+=8; | |
| 15395 | ✗ | yofs+=8; | |
| 15396 | } | ||
| 15397 | ✗ | } | |
| 15398 | else | ||
| 15399 | { | ||
| 15400 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1628 times.
|
1628 | if(!dmisc2) |
| 15401 | { | ||
| 15402 | 1628 | enemy::draw(dest); | |
| 15403 | 1628 | } | |
| 15404 | else | ||
| 15405 | { | ||
| 15406 | ✗ | xofs-=8; | |
| 15407 | ✗ | yofs-=8; | |
| 15408 | ✗ | enemy::draw(dest); | |
| 15409 | ✗ | xofs+=16; | |
| 15410 | ✗ | enemy::draw(dest); | |
| 15411 | ✗ | yofs+=16; | |
| 15412 | ✗ | enemy::draw(dest); | |
| 15413 | ✗ | xofs-=16; | |
| 15414 | ✗ | enemy::draw(dest); | |
| 15415 | ✗ | xofs+=8; | |
| 15416 | ✗ | yofs-=8; | |
| 15417 | } | ||
| 15418 | } | ||
| 15419 | 1628 | } | |
| 15420 | |||
| 15421 | 20 | esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) | |
| 15422 | 20 | { | |
| 15423 | 20 | id=misc=clk; | |
| 15424 | 20 | dir = clk & 3; | |
| 15425 | 20 | clk=0; | |
| 15426 | 20 | mainguy=count_enemy=false; | |
| 15427 | 20 | dummy_bool[0]=false; | |
| 15428 | 20 | item_set=0; | |
| 15429 | 20 | bgsfx=-1; | |
| 15430 | 20 | deadsfx = WAV_EDEAD; | |
| 15431 | 20 | flags &= (~guy_neverret); | |
| 15432 | 20 | isCore = false; | |
| 15433 | //Probably will be buggy. -Z 12 AUG 2020 | ||
| 15434 | 20 | SIZEflags = d->SIZEflags; | |
| 15435 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 15436 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 15437 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 15438 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } |
| 15439 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; |
| 15440 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; |
| 15441 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; |
| 15442 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; |
| 15443 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; |
| 15444 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 15445 |
1/4✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs; |
| 15446 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 15447 | { | ||
| 15448 | ✗ | yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); | |
| 15449 | ✗ | } | |
| 15450 | |||
| 15451 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
20 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs; |
| 15452 | 20 | } | |
| 15453 | |||
| 15454 | 5230 | bool esManhandla::animate(int32_t index) | |
| 15455 | { | ||
| 15456 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5230 times.
|
5230 | if(switch_hooked) return enemy::animate(index); |
| 15457 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 5086 times.
|
5230 | if(dying) |
| 15458 | 144 | return Dead(index); | |
| 15459 | |||
| 15460 |
2/2✓ Branch 0 taken 328 times.
✓ Branch 1 taken 4758 times.
|
5086 | if(clk==0) |
| 15461 | { | ||
| 15462 | 328 | removearmos(x,y,ffcactivated); | |
| 15463 | 328 | } | |
| 15464 | |||
| 15465 |
2/2✓ Branch 0 taken 4354 times.
✓ Branch 1 taken 732 times.
|
5086 | if(--clk2<=0) |
| 15466 | { | ||
| 15467 | 732 | clk2=unsigned(zc_oldrand())%5+5; | |
| 15468 | 732 | clk3^=1; | |
| 15469 | 732 | } | |
| 15470 | |||
| 15471 |
2/2✓ Branch 0 taken 44 times.
✓ Branch 1 taken 5042 times.
|
5086 | if(!(zc_oldrand()&127)) |
| 15472 | { | ||
| 15473 | 44 | addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez); | |
| 15474 | 44 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 15475 | 44 | } | |
| 15476 | |||
| 15477 | 5086 | return enemy::animate(index); | |
| 15478 | 5230 | } | |
| 15479 | |||
| 15480 | 5222 | void esManhandla::draw(BITMAP *dest) | |
| 15481 | { | ||
| 15482 | 5222 | tile=o_tile; | |
| 15483 | 5222 | int32_t fdiv = frate/4; | |
| 15484 |
1/2✓ Branch 0 taken 5222 times.
✗ Branch 1 not taken.
|
5222 | int32_t efrate = fdiv == 0 ? 0 : clk/fdiv; |
| 15485 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5222 times.
|
5222 | int32_t f2=get_qr(qr_NEWENEMYTILES)? |
| 15486 | 5222 | efrate:((clk>=(frate>>1))?1:0); | |
| 15487 | |||
| 15488 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5222 times.
|
5222 | if(get_qr(qr_NEWENEMYTILES)) |
| 15489 | { | ||
| 15490 | ✗ | switch(misc&3) | |
| 15491 | { | ||
| 15492 | case up: | ||
| 15493 | ✗ | break; | |
| 15494 | |||
| 15495 | case down: | ||
| 15496 | ✗ | tile+=4; | |
| 15497 | ✗ | break; | |
| 15498 | |||
| 15499 | case left: | ||
| 15500 | ✗ | tile+=8; | |
| 15501 | ✗ | break; | |
| 15502 | |||
| 15503 | case right: | ||
| 15504 | ✗ | tile+=12; | |
| 15505 | ✗ | break; | |
| 15506 | } | ||
| 15507 | |||
| 15508 | ✗ | tile+=f2; | |
| 15509 | ✗ | } | |
| 15510 | else | ||
| 15511 | { | ||
| 15512 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 1029 times.
✓ Branch 2 taken 1058 times.
✓ Branch 3 taken 1539 times.
✓ Branch 4 taken 1596 times.
|
5222 | switch(misc&3) |
| 15513 | { | ||
| 15514 | case down: | ||
| 15515 | 1539 | flip=2; | |
| 15516 | |||
| 15517 | [[fallthrough]]; | ||
| 15518 | case up: | ||
| 15519 | 2568 | tile=(clk3)?188:189; | |
| 15520 | 2568 | break; | |
| 15521 | |||
| 15522 | case right: | ||
| 15523 | 1596 | flip=1; | |
| 15524 | [[fallthrough]]; | ||
| 15525 | |||
| 15526 | case left: | ||
| 15527 | 2654 | tile=(clk3)?186:187; | |
| 15528 | 2654 | break; | |
| 15529 | } | ||
| 15530 | } | ||
| 15531 | |||
| 15532 | 5222 | enemy::draw(dest); | |
| 15533 | 5222 | } | |
| 15534 | |||
| 15535 | 3 | eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk) | |
| 15536 | 3 | { | |
| 15537 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if ( !(editorflags & ENEMY_FLAG5) ) |
| 15538 | { | ||
| 15539 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | x = 120; |
| 15540 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | y = 48; |
| 15541 | 3 | } | |
| 15542 | else | ||
| 15543 | { | ||
| 15544 | ✗ | if ( !(editorflags & ENEMY_FLAG6) ) | |
| 15545 | { | ||
| 15546 | ✗ | x = X; y = Y; | |
| 15547 | ✗ | } | |
| 15548 | else | ||
| 15549 | { | ||
| 15550 | ✗ | x = X+8; y = Y; | |
| 15551 | } | ||
| 15552 | } | ||
| 15553 | 3 | hzsz = 32; // can't be jumped. | |
| 15554 | 3 | flameclk=0; | |
| 15555 | 3 | misc=clk; // total head count | |
| 15556 | 3 | clk3=clk; // live head count | |
| 15557 | 3 | clk=0; | |
| 15558 | 3 | clk2=60; // fire ball clock | |
| 15559 | // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp; | ||
| 15560 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp; |
| 15561 | 3 | dir = down; | |
| 15562 | 3 | hxofs=4; | |
| 15563 | 3 | hit_width=8; | |
| 15564 | // frate=17*4; | ||
| 15565 | 3 | fading=fade_blue_poof; | |
| 15566 | //nets+5420; | ||
| 15567 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if(get_qr(qr_NEWENEMYTILES)) |
| 15568 | { | ||
| 15569 | /* | ||
| 15570 | necktile=o_tile+8; | ||
| 15571 | if (dmisc3) | ||
| 15572 | { | ||
| 15573 | necktile+=8; | ||
| 15574 | } | ||
| 15575 | */ | ||
| 15576 | ✗ | necktile=o_tile+dmisc6; | |
| 15577 | ✗ | } | |
| 15578 | else | ||
| 15579 | { | ||
| 15580 | 3 | necktile=s_tile; | |
| 15581 | } | ||
| 15582 | 3 | } | |
| 15583 | |||
| 15584 | 1804 | bool eGleeok::animate(int32_t index) | |
| 15585 | { | ||
| 15586 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1804 times.
|
1804 | if(switch_hooked) return enemy::animate(index); |
| 15587 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1750 times.
|
1804 | if(dying) |
| 15588 | 54 | return Dead(index); | |
| 15589 | |||
| 15590 |
2/2✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 8 times.
|
1750 | if(clk==0) |
| 15591 | { | ||
| 15592 | 8 | removearmos(x,y,ffcactivated); | |
| 15593 | 8 | } | |
| 15594 | |||
| 15595 | // Check if a head was killed somehow... | ||
| 15596 |
2/2✓ Branch 0 taken 877 times.
✓ Branch 1 taken 873 times.
|
1750 | if(index+1+clk3>=guys.Count()) |
| 15597 | 873 | clk3=guys.Count()-index-1; | |
| 15598 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1750 times.
|
1750 | if(index+1+misc>=guys.Count()) |
| 15599 | 1750 | misc=guys.Count()-index-1; | |
| 15600 | |||
| 15601 | //fix for the "kill all enemies" item | ||
| 15602 |
1/2✓ Branch 0 taken 1750 times.
✗ Branch 1 not taken.
|
1750 | if(hp==-1000) |
| 15603 | { | ||
| 15604 | ✗ | for(int32_t i=0; i<clk3; ++i) | |
| 15605 | { | ||
| 15606 | // I haven't seen this fail, but it seems like it ought to be | ||
| 15607 | // possible, so I'm checking for it. - Saf | ||
| 15608 | ✗ | if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF)) | |
| 15609 | ✗ | break; | |
| 15610 | ✗ | ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head, | |
| 15611 | ✗ | ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it, | |
| 15612 | ✗ | ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame, | |
| 15613 | ✗ | ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good | |
| 15614 | ✗ | } | |
| 15615 | |||
| 15616 | ✗ | clk3=0; | |
| 15617 | |||
| 15618 | ✗ | for(int32_t i=0; i<misc; i++) | |
| 15619 | { | ||
| 15620 | ✗ | if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF)) | |
| 15621 | ✗ | break; | |
| 15622 | ✗ | ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear | |
| 15623 | ✗ | } | |
| 15624 | ✗ | } | |
| 15625 | |||
| 15626 |
2/2✓ Branch 0 taken 3712 times.
✓ Branch 1 taken 1750 times.
|
5462 | for(int32_t i=0; i<clk3; i++) |
| 15627 | { | ||
| 15628 | 3712 | enemy *head = ((enemy*)guys.spr(index+i+1)); | |
| 15629 | 3712 | head->dummy_int[1]=necktile; | |
| 15630 | 3712 | head->parent_script_UID = this->script_UID; | |
| 15631 | |||
| 15632 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3712 times.
|
3712 | if(get_qr(qr_NEWENEMYTILES)) |
| 15633 | { | ||
| 15634 | ✗ | head->dummy_int[2]=o_tile+dmisc8; //connected head tile | |
| 15635 | ✗ | head->dummy_int[3]=o_tile+dmisc9; //flying head tile | |
| 15636 | ✗ | } | |
| 15637 | else | ||
| 15638 | { | ||
| 15639 | 3712 | head->dummy_int[2]=necktile+1; //connected head tile | |
| 15640 | 3712 | head->dummy_int[3]=necktile+2; //flying head tile | |
| 15641 | } | ||
| 15642 | |||
| 15643 | 3712 | head->dmisc5=dmisc5; //neck segments | |
| 15644 | |||
| 15645 | /* | ||
| 15646 | if (dmisc3) | ||
| 15647 | { | ||
| 15648 | head->dummy_bool[0]=true; | ||
| 15649 | } | ||
| 15650 | */ | ||
| 15651 |
2/2✓ Branch 0 taken 3609 times.
✓ Branch 1 taken 103 times.
|
3712 | if(head->hclk) |
| 15652 | { | ||
| 15653 |
2/2✓ Branch 0 taken 79 times.
✓ Branch 1 taken 24 times.
|
103 | if(hclk==0) |
| 15654 | { | ||
| 15655 | 24 | hp -= 1000 - head->hp; | |
| 15656 | 24 | hclk = 33; | |
| 15657 | |||
| 15658 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
|
24 | if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x))); |
| 15659 | |||
| 15660 | 24 | sfx(WAV_EHIT,pan(int32_t(head->x))); | |
| 15661 | 24 | } | |
| 15662 | |||
| 15663 | 103 | head->hclk = 0; | |
| 15664 | 103 | } | |
| 15665 | |||
| 15666 | // Must be set in case of naughty ZScripts | ||
| 15667 | 3712 | head->hp = 1000; | |
| 15668 | 3712 | } | |
| 15669 | |||
| 15670 |
2/2✓ Branch 0 taken 1741 times.
✓ Branch 1 taken 9 times.
|
1750 | if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult()) |
| 15671 | { | ||
| 15672 | 9 | ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off | |
| 15673 | 9 | hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult(); | |
| 15674 | 9 | } | |
| 15675 | |||
| 15676 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1750 times.
|
1750 | if(!dmisc3) |
| 15677 | { | ||
| 15678 |
4/4✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1650 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 75 times.
|
1750 | if(++clk2>72 && !(zc_oldrand()&3)) |
| 15679 | { | ||
| 15680 | 25 | int32_t i=zc_oldrand()%misc; | |
| 15681 | 25 | enemy *head = ((enemy*)guys.spr(index+i+1)); | |
| 15682 | 25 | addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez); | |
| 15683 | 25 | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 15684 | 25 | clk2=0; | |
| 15685 | 25 | } | |
| 15686 | 1750 | } | |
| 15687 | else | ||
| 15688 | { | ||
| 15689 | ✗ | if(++clk2>100 && !(zc_oldrand()&3)) | |
| 15690 | { | ||
| 15691 | ✗ | enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1)); | |
| 15692 | ✗ | head->timer=zc_oldrand()%50+50; | |
| 15693 | ✗ | clk2=0; | |
| 15694 | ✗ | } | |
| 15695 | } | ||
| 15696 | |||
| 15697 |
3/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1747 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
1750 | if((hp<=0 && !immortal)) |
| 15698 | { | ||
| 15699 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
|
12 | for(int32_t i=0; i<misc; i++) |
| 15700 | 9 | ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear | |
| 15701 | |||
| 15702 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if(flags&guy_neverret) never_return(index); |
| 15703 | 3 | } | |
| 15704 | |||
| 15705 | 1750 | return enemy::animate(index); | |
| 15706 | 1804 | } | |
| 15707 | |||
| 15708 | ✗ | int32_t eGleeok::takehit(weapon*,weapon*) | |
| 15709 | { | ||
| 15710 | ✗ | return 0; | |
| 15711 | } | ||
| 15712 | |||
| 15713 | 1804 | void eGleeok::draw(BITMAP *dest) | |
| 15714 | { | ||
| 15715 | 1804 | tile=o_tile; | |
| 15716 | |||
| 15717 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1750 times.
|
1804 | if(dying) |
| 15718 | { | ||
| 15719 | 54 | enemy::draw(dest); | |
| 15720 | 54 | return; | |
| 15721 | } | ||
| 15722 | |||
| 15723 | 1750 | int32_t f=clk/17; | |
| 15724 | |||
| 15725 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1750 times.
|
1750 | if(get_qr(qr_NEWENEMYTILES)) |
| 15726 | { | ||
| 15727 | // body | ||
| 15728 | ✗ | xofs=-8; | |
| 15729 | ✗ | yofs=32; | |
| 15730 | |||
| 15731 | ✗ | switch(f) | |
| 15732 | |||
| 15733 | { | ||
| 15734 | case 0: | ||
| 15735 | ✗ | tile+=0; | |
| 15736 | ✗ | break; | |
| 15737 | |||
| 15738 | case 1: | ||
| 15739 | ✗ | tile+=2; | |
| 15740 | ✗ | break; | |
| 15741 | |||
| 15742 | case 2: | ||
| 15743 | ✗ | tile+=4; | |
| 15744 | ✗ | break; | |
| 15745 | |||
| 15746 | default: | ||
| 15747 | ✗ | tile+=6; | |
| 15748 | ✗ | break; | |
| 15749 | } | ||
| 15750 | ✗ | } | |
| 15751 | else | ||
| 15752 | { | ||
| 15753 | // body | ||
| 15754 | 1750 | xofs=-8; | |
| 15755 | 1750 | yofs=32; | |
| 15756 | |||
| 15757 |
3/3✓ Branch 0 taken 1478 times.
✓ Branch 1 taken 136 times.
✓ Branch 2 taken 136 times.
|
1750 | switch(f) |
| 15758 | { | ||
| 15759 | case 0: | ||
| 15760 | 136 | tile+=0; | |
| 15761 | 136 | break; | |
| 15762 | |||
| 15763 | case 2: | ||
| 15764 | 136 | tile+=4; | |
| 15765 | 136 | break; | |
| 15766 | |||
| 15767 | default: | ||
| 15768 | 1478 | tile+=2; | |
| 15769 | 1478 | break; | |
| 15770 | } | ||
| 15771 | } | ||
| 15772 | |||
| 15773 | 1750 | enemy::drawblock(dest,15); | |
| 15774 | 1804 | } | |
| 15775 | |||
| 15776 | 1804 | void eGleeok::draw2(BITMAP *dest) | |
| 15777 | { | ||
| 15778 | // the neck stub | ||
| 15779 | 1804 | tile=necktile; | |
| 15780 | 1804 | xofs=0; | |
| 15781 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1804 times.
|
1804 | yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); |
| 15782 | |||
| 15783 |
1/2✓ Branch 0 taken 1804 times.
✗ Branch 1 not taken.
|
1804 | if(get_qr(qr_NEWENEMYTILES)) |
| 15784 | { | ||
| 15785 | ✗ | tile+=((clk&24)>>3); | |
| 15786 | ✗ | } | |
| 15787 | |||
| 15788 |
3/4✓ Branch 0 taken 1750 times.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1750 times.
|
1804 | if(hp > 0 && !dont_draw()) |
| 15789 | { | ||
| 15790 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1750 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1750 | if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet))) |
| 15791 | ✗ | sprite::drawcloaked(dest); | |
| 15792 | else | ||
| 15793 | 1750 | sprite::draw(dest); | |
| 15794 | 1750 | } | |
| 15795 | 1804 | } | |
| 15796 | |||
| 15797 |
3/6✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
|
18 | esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt) |
| 15798 | 9 | { | |
| 15799 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | xoffset=0; |
| 15800 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | yoffset=(zfix)((dmisc5*4+2)); |
| 15801 | // dummy_bool[0]=false; | ||
| 15802 | 9 | timer=0; | |
| 15803 | /* fixing */ | ||
| 15804 | 9 | hp=1000; | |
| 15805 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | step=1; |
| 15806 | 9 | item_set=0; | |
| 15807 | //x=120; y=70; | ||
| 15808 |
4/8✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
|
9 | x = xoffset+parent->x; |
| 15809 |
4/8✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
|
9 | y = yoffset+parent->y; |
| 15810 | 9 | hxofs=4; | |
| 15811 | 9 | hit_width=8; | |
| 15812 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
9 | yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); |
| 15813 | 9 | clk2=clk; // how int32_t to wait before moving first time | |
| 15814 | 9 | clk=0; | |
| 15815 | 9 | mainguy=count_enemy=false; | |
| 15816 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | dir=zc_oldrand(); |
| 15817 | 9 | clk3=((dir&2)>>1)+2; // left or right | |
| 15818 | 9 | dir&=1; // up or down | |
| 15819 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | dmisc5=vbound(dmisc5,1,255); |
| 15820 | 9 | isCore = false; | |
| 15821 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | parentCore = parent->getUID(); |
| 15822 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 9 times.
|
45 | for(int32_t i=0; i<dmisc5; i++) |
| 15823 | { | ||
| 15824 | 36 | nxoffset[i] = 0; | |
| 15825 | 36 | nyoffset[i] = 0; | |
| 15826 |
2/4✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 | nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5); |
| 15827 |
2/4✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
|
36 | ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5); |
| 15828 | 36 | } | |
| 15829 | |||
| 15830 | 9 | necktile=0; | |
| 15831 | //TODO compatibility? -DD | ||
| 15832 | /* | ||
| 15833 | for(int32_t i=0; i<4; i++) | ||
| 15834 | { | ||
| 15835 | nx[i]=124; | ||
| 15836 | ny[i]=i*6+48; | ||
| 15837 | }*/ | ||
| 15838 | 9 | bgsfx=-1; | |
| 15839 | //no need for deadsfx | ||
| 15840 | 9 | } | |
| 15841 | |||
| 15842 | 5112 | bool esGleeok::animate(int32_t index) | |
| 15843 | { | ||
| 15844 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5112 times.
|
5112 | if(switch_hooked) return enemy::animate(index); |
| 15845 | // don't call removearmos() - it's a segment. | ||
| 15846 | |||
| 15847 | 5112 | dmisc5=vbound(dmisc5,1,255); | |
| 15848 | |||
| 15849 |
2/2✓ Branch 0 taken 1409 times.
✓ Branch 1 taken 3703 times.
|
5112 | if(misc == 0) |
| 15850 | { | ||
| 15851 | 3703 | x = (xoffset+parent->x); | |
| 15852 | 3703 | y = (yoffset+parent->y); | |
| 15853 | |||
| 15854 |
2/2✓ Branch 0 taken 14812 times.
✓ Branch 1 taken 3703 times.
|
18515 | for(int32_t i=0; i<dmisc5; i++) |
| 15855 | { | ||
| 15856 | 14812 | nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i]; | |
| 15857 | 14812 | ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i]; | |
| 15858 | 14812 | } | |
| 15859 | 3703 | } | |
| 15860 | |||
| 15861 | // set up the head tiles | ||
| 15862 | // headtile=nets+5588; //5580, actually. must adjust for direction later on | ||
| 15863 | /* | ||
| 15864 | if (dummy_bool[0]) //if this is a flame gleeok | ||
| 15865 | { | ||
| 15866 | headtile+=180; | ||
| 15867 | } | ||
| 15868 | */ | ||
| 15869 | 5112 | headtile=dummy_int[2]; //5580, actually. must adjust for direction later on | |
| 15870 | 5112 | flyingheadtile=dummy_int[3]; | |
| 15871 | |||
| 15872 | // set up the neck tiles | ||
| 15873 | 5112 | necktile=dummy_int[1]; | |
| 15874 | |||
| 15875 |
1/2✓ Branch 0 taken 5112 times.
✗ Branch 1 not taken.
|
5112 | if(get_qr(qr_NEWENEMYTILES)) |
| 15876 | { | ||
| 15877 | ✗ | necktile+=((clk&24)>>3); | |
| 15878 | ✗ | } | |
| 15879 | |||
| 15880 | /* | ||
| 15881 | else | ||
| 15882 | { | ||
| 15883 | necktile=145; | ||
| 15884 | } | ||
| 15885 | */ | ||
| 15886 | // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145) | ||
| 15887 | |||
| 15888 |
4/5✗ Branch 0 not taken.
✓ Branch 1 taken 3703 times.
✓ Branch 2 taken 1394 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 9 times.
|
5112 | switch(misc) |
| 15889 | { | ||
| 15890 | case 0: // live head | ||
| 15891 | // set up the attached head tiles | ||
| 15892 | 3703 | tile=headtile; | |
| 15893 | |||
| 15894 |
1/2✓ Branch 0 taken 3703 times.
✗ Branch 1 not taken.
|
3703 | if(get_qr(qr_NEWENEMYTILES)) |
| 15895 | { | ||
| 15896 | ✗ | tile+=((clk&24)>>3); | |
| 15897 | /* | ||
| 15898 | if (dummy_bool[0]) { | ||
| 15899 | tile+=1561; | ||
| 15900 | } | ||
| 15901 | */ | ||
| 15902 | ✗ | } | |
| 15903 | |||
| 15904 | /* | ||
| 15905 | else | ||
| 15906 | { | ||
| 15907 | tile=146; | ||
| 15908 | } | ||
| 15909 | */ | ||
| 15910 |
4/4✓ Branch 0 taken 918 times.
✓ Branch 1 taken 2785 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 807 times.
|
3703 | if(++clk2>=0 && !(clk2&3)) |
| 15911 | { | ||
| 15912 |
2/2✓ Branch 0 taken 792 times.
✓ Branch 1 taken 15 times.
|
807 | if(y<= (int32_t)parent->y + 8) dir=down; |
| 15913 | |||
| 15914 |
2/2✓ Branch 0 taken 789 times.
✓ Branch 1 taken 18 times.
|
807 | if(y>= (int32_t)parent->y + dmisc5*8) dir = up; |
| 15915 | |||
| 15916 |
4/4✓ Branch 0 taken 76 times.
✓ Branch 1 taken 731 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 1 times.
|
807 | if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31)) |
| 15917 | { | ||
| 15918 | 1 | dir^=1; | |
| 15919 | 1 | } | |
| 15920 | |||
| 15921 | 807 | zfix tempx = x; | |
| 15922 | 807 | zfix tempy = y; | |
| 15923 | |||
| 15924 | 807 | sprite::move(step); | |
| 15925 | 807 | xoffset += (x-tempx); | |
| 15926 | 807 | yoffset += (y-tempy); | |
| 15927 | |||
| 15928 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 771 times.
|
807 | if(clk2>=4) |
| 15929 | { | ||
| 15930 | 36 | clk3^=1; | |
| 15931 | 36 | clk2=-4; | |
| 15932 | 36 | } | |
| 15933 | else | ||
| 15934 | { | ||
| 15935 |
2/2✓ Branch 0 taken 759 times.
✓ Branch 1 taken 12 times.
|
771 | if(x <= (int32_t)parent->x-(dmisc5*6)) |
| 15936 | { | ||
| 15937 | 12 | clk3=right; | |
| 15938 | 12 | } | |
| 15939 | |||
| 15940 |
2/2✓ Branch 0 taken 766 times.
✓ Branch 1 taken 5 times.
|
771 | if(x >= (int32_t)parent->x+(dmisc5*6)) |
| 15941 | { | ||
| 15942 | 5 | clk3=left; | |
| 15943 | 5 | } | |
| 15944 | |||
| 15945 |
4/4✓ Branch 0 taken 504 times.
✓ Branch 1 taken 267 times.
✓ Branch 2 taken 470 times.
✓ Branch 3 taken 34 times.
|
771 | if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15)) |
| 15946 | { | ||
| 15947 | 34 | clk3^=1; // x jig | |
| 15948 | 34 | } | |
| 15949 | else | ||
| 15950 | { | ||
| 15951 |
4/4✓ Branch 0 taken 232 times.
✓ Branch 1 taken 505 times.
✓ Branch 2 taken 227 times.
✓ Branch 3 taken 5 times.
|
737 | if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31)) |
| 15952 | { | ||
| 15953 | 5 | clk3^=1; // x switch back | |
| 15954 | 5 | } | |
| 15955 | |||
| 15956 | 737 | clk2=-4; | |
| 15957 | } | ||
| 15958 | } | ||
| 15959 | |||
| 15960 | 807 | zc_swap(dir,clk3); | |
| 15961 | 807 | tempx = x; | |
| 15962 | 807 | tempy = y; | |
| 15963 | 807 | sprite::move(step); | |
| 15964 | 807 | xoffset += (x-tempx); | |
| 15965 | 807 | yoffset += (y-tempy); | |
| 15966 | 807 | zc_swap(dir,clk3); | |
| 15967 | |||
| 15968 |
2/2✓ Branch 0 taken 2421 times.
✓ Branch 1 taken 807 times.
|
3228 | for(int32_t i=1; i<dmisc5; i++) |
| 15969 | { | ||
| 15970 | 2421 | nxoffset[i] = (zc_oldrand()%3); | |
| 15971 | 2421 | nyoffset[i] = (zc_oldrand()%3); | |
| 15972 | 2421 | } | |
| 15973 | 807 | } | |
| 15974 | |||
| 15975 | 3703 | break; | |
| 15976 | |||
| 15977 | case 1: // flying head | ||
| 15978 |
2/2✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1256 times.
|
1394 | if(clk>=0) |
| 15979 | |||
| 15980 | { | ||
| 15981 | 1256 | variable_walk_8(rate,homing,hrate,spw_floater); | |
| 15982 | 1256 | } | |
| 15983 | |||
| 15984 | 1394 | break; | |
| 15985 | |||
| 15986 | // the following are messages sent from the main guy... | ||
| 15987 | case -1: // got chopped off | ||
| 15988 | { | ||
| 15989 | 6 | misc=1; | |
| 15990 | 6 | superman=1; | |
| 15991 | 6 | hxofs=xofs=0; | |
| 15992 | 6 | hit_width=16; | |
| 15993 | 6 | cs=8; | |
| 15994 | 6 | clk=-24; | |
| 15995 | 6 | clk2=40; | |
| 15996 | 6 | dir=(zc_oldrand()&7)+8; | |
| 15997 | 6 | step=8.0/9.0; | |
| 15998 | } | ||
| 15999 | 6 | break; | |
| 16000 | |||
| 16001 | case -2: // the big guy is dead | ||
| 16002 | 9 | return true; | |
| 16003 | } | ||
| 16004 | |||
| 16005 |
1/2✓ Branch 0 taken 5103 times.
✗ Branch 1 not taken.
|
5103 | if(timer) |
| 16006 | { | ||
| 16007 | ✗ | if(!(timer%8)) | |
| 16008 | { | ||
| 16009 | ✗ | FireBreath(true); | |
| 16010 | ✗ | } | |
| 16011 | |||
| 16012 | ✗ | --timer; | |
| 16013 | ✗ | } | |
| 16014 | |||
| 16015 | 5103 | return enemy::animate(index); | |
| 16016 | 5112 | } | |
| 16017 | |||
| 16018 | 110 | int32_t esGleeok::takehit(weapon *w, weapon* realweap) | |
| 16019 | { | ||
| 16020 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
110 | if ((editorflags & ENEMY_FLAG7) && misc == 1) |
| 16021 | { | ||
| 16022 | ✗ | int32_t wpnId = w->id; | |
| 16023 | |||
| 16024 | ✗ | if(dying) | |
| 16025 | ✗ | return 0; | |
| 16026 | |||
| 16027 | ✗ | switch(wpnId) | |
| 16028 | { | ||
| 16029 | case wLitBomb: | ||
| 16030 | case wLitSBomb: | ||
| 16031 | case wBait: | ||
| 16032 | case wWhistle: | ||
| 16033 | case wFire: | ||
| 16034 | case wWind: | ||
| 16035 | case wSSparkle: | ||
| 16036 | case wFSparkle: | ||
| 16037 | case wPhantom: | ||
| 16038 | ✗ | return 0; | |
| 16039 | |||
| 16040 | case wHookshot: | ||
| 16041 | case wBrang: | ||
| 16042 | case wBeam: | ||
| 16043 | case wArrow: | ||
| 16044 | case wMagic: | ||
| 16045 | case wBomb: | ||
| 16046 | case wSBomb: | ||
| 16047 | ✗ | sfx(WAV_CHINK,pan(int32_t(x))); | |
| 16048 | ✗ | break; | |
| 16049 | default: | ||
| 16050 | ✗ | break; | |
| 16051 | } | ||
| 16052 | |||
| 16053 | ✗ | return 1; | |
| 16054 | } | ||
| 16055 | else | ||
| 16056 | { | ||
| 16057 | 110 | int32_t ret = enemy::takehit(w,realweap); | |
| 16058 | |||
| 16059 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 103 times.
|
110 | if(ret==-1) |
| 16060 | 103 | return 2; // force it to wait a frame before checking sword attacks again | |
| 16061 | |||
| 16062 | 7 | return ret; | |
| 16063 | } | ||
| 16064 | 110 | } | |
| 16065 | |||
| 16066 | 5112 | void esGleeok::draw(BITMAP *dest) | |
| 16067 | { | ||
| 16068 | 5112 | dmisc5=vbound(dmisc5,1,255); | |
| 16069 | |||
| 16070 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 3712 times.
✓ Branch 2 taken 1400 times.
|
5112 | switch(misc) |
| 16071 | { | ||
| 16072 | case 0: //neck | ||
| 16073 |
1/2✓ Branch 0 taken 3712 times.
✗ Branch 1 not taken.
|
3712 | if(!dont_draw()) |
| 16074 | { | ||
| 16075 |
2/2✓ Branch 0 taken 11136 times.
✓ Branch 1 taken 3712 times.
|
14848 | for(int32_t i=1; i<dmisc5; i++) //draw the neck |
| 16076 | { | ||
| 16077 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11136 times.
|
11136 | if(get_qr(qr_NEWENEMYTILES)) |
| 16078 | { | ||
| 16079 | ✗ | if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet))) | |
| 16080 | ✗ | overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0); | |
| 16081 | else | ||
| 16082 | ✗ | overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0); | |
| 16083 | ✗ | } | |
| 16084 | else | ||
| 16085 | { | ||
| 16086 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11136 | if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet))) |
| 16087 | ✗ | overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0); | |
| 16088 | else | ||
| 16089 | 11136 | overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0); | |
| 16090 | } | ||
| 16091 | 11136 | } | |
| 16092 | 3712 | } | |
| 16093 | |||
| 16094 | 3712 | break; | |
| 16095 | |||
| 16096 | case 1: //flying head | ||
| 16097 | 1400 | tile=flyingheadtile; | |
| 16098 | |||
| 16099 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1400 times.
|
1400 | if(get_qr(qr_NEWENEMYTILES)) |
| 16100 | { | ||
| 16101 | ✗ | tile+=((clk&24)>>3); | |
| 16102 | ✗ | break; | |
| 16103 | } | ||
| 16104 | |||
| 16105 | /* | ||
| 16106 | else | ||
| 16107 | { | ||
| 16108 | tile=(clk&1)?147:148; | ||
| 16109 | break; | ||
| 16110 | } | ||
| 16111 | */ | ||
| 16112 | 1400 | } | |
| 16113 | 5112 | } | |
| 16114 | |||
| 16115 | 5112 | void esGleeok::draw2(BITMAP *dest) | |
| 16116 | { | ||
| 16117 | 5112 | enemy::draw(dest); | |
| 16118 | 5112 | } | |
| 16119 | |||
| 16120 | 4 | ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk) | |
| 16121 | 4 | { | |
| 16122 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if ( !(editorflags & ENEMY_FLAG5) ) |
| 16123 | { | ||
| 16124 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | x = 128; |
| 16125 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | y = 48; |
| 16126 | 4 | } | |
| 16127 | ✗ | else { x = X; y = Y; } | |
| 16128 | 4 | adjusted=false; | |
| 16129 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | dir=(zc_oldrand()&7)+8; |
| 16130 | //step=0.25; | ||
| 16131 | 4 | flycnt=dmisc1; | |
| 16132 | 4 | flycnt2=dmisc2; | |
| 16133 | 4 | loopcnt=0; | |
| 16134 | 4 | clk4 = 0; | |
| 16135 | 4 | clk5 = 0; | |
| 16136 | 4 | clk6 = 0; | |
| 16137 | 4 | clk7 = 0; | |
| 16138 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0! |
| 16139 | 4 | SIZEflags = d->SIZEflags; | |
| 16140 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. |
| 16141 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | else if (dmisc10 == 1) { txsz = 2; extend = 3; } |
| 16142 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 16143 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 16144 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; } |
| 16145 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | else if (dmisc10 == 1) { tysz = 2; extend = 3; } |
| 16146 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width; |
| 16147 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | else if (dmisc10 == 1) hit_width = 32; |
| 16148 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height; |
| 16149 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz; |
| 16150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs; |
| 16151 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | else if (dmisc10 == 1) hxofs = -8; |
| 16152 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs; |
| 16153 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 16154 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs; |
| 16155 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | else if (dmisc10 == 1) xofs = -8; |
| 16156 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) |
| 16157 | { | ||
| 16158 | ✗ | yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 16159 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 16160 | ✗ | } | |
| 16161 |
1/6✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8; |
| 16162 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (editorflags & ENEMY_FLAG8) misc = 1; |
| 16163 | |||
| 16164 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
4 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs; |
| 16165 | |||
| 16166 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (dmisc29 == 0) |
| 16167 | { | ||
| 16168 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | if(!dmisc4) |
| 16169 | { | ||
| 16170 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (dmisc10) dmisc29 = (90 / 3); |
| 16171 | 1 | else dmisc29 = (84 / 3); | |
| 16172 | 1 | } | |
| 16173 | else | ||
| 16174 | { | ||
| 16175 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (dmisc10) dmisc29 = (90 / 2); |
| 16176 | 3 | else dmisc29 = (84 / 2); | |
| 16177 | } | ||
| 16178 | 4 | } | |
| 16179 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (dmisc30 == 0) |
| 16180 | { | ||
| 16181 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | if(!dmisc4) |
| 16182 | { | ||
| 16183 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (dmisc10) dmisc30 = (90 / 3)*0.5; |
| 16184 | 1 | else dmisc30 = (84 / 3)*0.5; | |
| 16185 | 1 | } | |
| 16186 | else | ||
| 16187 | { | ||
| 16188 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (dmisc10) dmisc30 = (90 / 2)*0.5; |
| 16189 | 3 | else dmisc30 = (84 / 2)*0.5; | |
| 16190 | } | ||
| 16191 | 4 | } | |
| 16192 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (dmisc31 == 0) |
| 16193 | { | ||
| 16194 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | if(!dmisc4) |
| 16195 | { | ||
| 16196 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (dmisc10) dmisc31 = (90 / 3)*2; |
| 16197 | 1 | else dmisc31 = (84 / 3)*2; | |
| 16198 | 1 | } | |
| 16199 | else | ||
| 16200 | { | ||
| 16201 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (dmisc10) dmisc31 = (90 / 2)*0.5; |
| 16202 | 3 | else dmisc31 = (84 / 2)*0.5; | |
| 16203 | } | ||
| 16204 | 4 | } | |
| 16205 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (dmisc32 == 0) |
| 16206 | { | ||
| 16207 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | if(!dmisc4) |
| 16208 | { | ||
| 16209 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (dmisc10) dmisc32 = (90 / 3); |
| 16210 | 1 | else dmisc32 = (84 / 3); | |
| 16211 | 1 | } | |
| 16212 | else | ||
| 16213 | { | ||
| 16214 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (dmisc10) dmisc32 = (90 / 2)*0.25; |
| 16215 | 3 | else dmisc32 = (84 / 2)*0.25; | |
| 16216 | } | ||
| 16217 | 4 | } | |
| 16218 | 4 | } | |
| 16219 | |||
| 16220 | 8070 | bool ePatra::animate(int32_t index) | |
| 16221 | { | ||
| 16222 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8070 times.
|
8070 | if(switch_hooked) return enemy::animate(index); |
| 16223 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 7998 times.
|
8070 | if(dying) |
| 16224 | { | ||
| 16225 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 72 times.
|
144 | for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++) |
| 16226 | { | ||
| 16227 | 72 | ((enemy*)guys.spr(i))->hp = -1000; | |
| 16228 | 72 | } | |
| 16229 | |||
| 16230 | 72 | return Dead(index); | |
| 16231 | } | ||
| 16232 | |||
| 16233 | 7998 | double basesize = 84; | |
| 16234 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | if (dmisc10) basesize = 90; |
| 16235 | 7998 | double halfsize = basesize / 2; | |
| 16236 | 7998 | double quartersize = halfsize / 2; | |
| 16237 | 7998 | double twothirdsize = (basesize / 3)*2; | |
| 16238 | 7998 | double onethirdsize = (basesize / 3); | |
| 16239 | |||
| 16240 | |||
| 16241 |
2/2✓ Branch 0 taken 7004 times.
✓ Branch 1 taken 994 times.
|
7998 | if(clk==0) |
| 16242 | { | ||
| 16243 | 994 | removearmos(x,y,ffcactivated); | |
| 16244 | 994 | } | |
| 16245 | |||
| 16246 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 7998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7998 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
7998 | if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16)) |
| 16247 | { | ||
| 16248 |
1/8✗ Branch 0 not taken.
✓ Branch 1 taken 7998 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
7998 | if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater); |
| 16249 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | if (loopcnt < 0) ++clk2; |
| 16250 |
2/2✓ Branch 0 taken 7906 times.
✓ Branch 1 taken 92 times.
|
7998 | if(++clk2>basesize) |
| 16251 | { | ||
| 16252 | 92 | clk2=0; | |
| 16253 |
2/12✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 92 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
92 | if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2)) |
| 16254 | { | ||
| 16255 |
2/2✓ Branch 0 taken 47 times.
✓ Branch 1 taken 45 times.
|
92 | if(loopcnt > 0) |
| 16256 | 47 | --loopcnt; | |
| 16257 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
|
45 | else if (loopcnt == 0) |
| 16258 | { | ||
| 16259 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 14 times.
|
45 | if((misc%dmisc6)==0) |
| 16260 | { | ||
| 16261 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if (dmisc21 > 0) loopcnt=-dmisc21; |
| 16262 | 14 | else loopcnt=dmisc7; | |
| 16263 | 14 | } | |
| 16264 | 45 | } | |
| 16265 | ✗ | else if (loopcnt == -1) loopcnt=dmisc7; | |
| 16266 | ✗ | else ++loopcnt; | |
| 16267 | |||
| 16268 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
92 | if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc; |
| 16269 | 92 | } | |
| 16270 | else | ||
| 16271 | { | ||
| 16272 | ✗ | loopcnt = 0; | |
| 16273 | ✗ | misc = 1; | |
| 16274 | } | ||
| 16275 | 92 | } | |
| 16276 | 7998 | } | |
| 16277 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | if (clk4 > 0) --clk4; |
| 16278 | |||
| 16279 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | if (clk6 < 0) |
| 16280 | { | ||
| 16281 | ✗ | if (dmisc5 == 1 || dmisc5 == 3) | |
| 16282 | { | ||
| 16283 | ✗ | if (get_qr(qr_NEWENEMYTILES)) | |
| 16284 | { | ||
| 16285 | ✗ | if (clk7 <= 0 || clk6 != -16) ++clk6; | |
| 16286 | ✗ | if (clk6 == 0) o_tile=d->e_tile; | |
| 16287 | else | ||
| 16288 | { | ||
| 16289 | ✗ | if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80); | |
| 16290 | ✗ | else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40); | |
| 16291 | } | ||
| 16292 | ✗ | } | |
| 16293 | ✗ | else clk6 = 0; | |
| 16294 | ✗ | } | |
| 16295 | ✗ | } | |
| 16296 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | else if (dmisc19) ++clk6; |
| 16297 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | if (clk5 < 0) ++clk5; |
| 16298 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | else if (dmisc19) ++clk5; |
| 16299 | |||
| 16300 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7998 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7998 | if (clk7 > 0 && clk6 >= -16) --clk7; |
| 16301 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | if (clk6 > 0) clk7 = 0; |
| 16302 | |||
| 16303 |
2/2✓ Branch 0 taken 30147 times.
✓ Branch 1 taken 7998 times.
|
38145 | for(int32_t i=index+1; i<index+flycnt+1; i++) |
| 16304 | { | ||
| 16305 | //outside ring | ||
| 16306 |
2/2✓ Branch 0 taken 30115 times.
✓ Branch 1 taken 32 times.
|
30147 | if(!adjusted) |
| 16307 | { | ||
| 16308 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
|
32 | if(get_qr(qr_NEWENEMYTILES)) |
| 16309 | { | ||
| 16310 | ✗ | ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8; | |
| 16311 | ✗ | enemy *s = ((enemy*)guys.spr(i)); | |
| 16312 | ✗ | s->parent_script_UID = this->script_UID; | |
| 16313 | ✗ | } | |
| 16314 | else | ||
| 16315 | { | ||
| 16316 | 32 | ((enemy*)guys.spr(i))->o_tile=o_tile+1; | |
| 16317 | 32 | enemy *s = ((enemy*)guys.spr(i)); | |
| 16318 | 32 | s->parent_script_UID = this->script_UID; | |
| 16319 | } | ||
| 16320 | |||
| 16321 | 32 | ((enemy*)guys.spr(i))->cs=dmisc9; | |
| 16322 | 32 | ((enemy*)guys.spr(i))->hp=dmisc3; | |
| 16323 | 32 | } | |
| 16324 | |||
| 16325 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 30119 times.
|
30147 | if(((enemy*)guys.spr(i))->hp <= 0) |
| 16326 | { | ||
| 16327 |
2/2✓ Branch 0 taken 55 times.
✓ Branch 1 taken 28 times.
|
83 | for(int32_t j=i; j<index+flycnt+flycnt2; j++) |
| 16328 | { | ||
| 16329 | 55 | guys.swap(j,j+1); | |
| 16330 | 55 | } | |
| 16331 | |||
| 16332 |
3/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
28 | if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100); |
| 16333 | 28 | } | |
| 16334 | else | ||
| 16335 | { | ||
| 16336 | 30119 | int32_t pos2 = ((enemy*)guys.spr(i))->misc; | |
| 16337 |
1/2✓ Branch 0 taken 30119 times.
✗ Branch 1 not taken.
|
30119 | double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize; |
| 16338 | |||
| 16339 |
2/2✓ Branch 0 taken 24791 times.
✓ Branch 1 taken 5328 times.
|
30119 | if(!dmisc4) //Big Ring |
| 16340 | { | ||
| 16341 | //maybe playing_field_offset here? | ||
| 16342 |
2/2✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 2523 times.
|
5328 | if(loopcnt>0) |
| 16343 | { | ||
| 16344 |
1/2✓ Branch 0 taken 2805 times.
✗ Branch 1 not taken.
|
2805 | guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29)); |
| 16345 |
1/2✓ Branch 0 taken 2805 times.
✗ Branch 1 not taken.
|
2805 | guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29)); |
| 16346 | 2805 | } | |
| 16347 | else | ||
| 16348 | { | ||
| 16349 | 2523 | guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29); | |
| 16350 | 2523 | guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29); | |
| 16351 | } | ||
| 16352 | |||
| 16353 | 5328 | temp_x=guys.spr(i)->x; | |
| 16354 | 5328 | temp_y=guys.spr(i)->y; | |
| 16355 | 5328 | } | |
| 16356 | else //Oval | ||
| 16357 | { | ||
| 16358 | 24791 | circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29); | |
| 16359 | 24791 | circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29); | |
| 16360 | |||
| 16361 |
2/2✓ Branch 0 taken 13217 times.
✓ Branch 1 taken 11574 times.
|
24791 | if(loopcnt>0) |
| 16362 | { | ||
| 16363 | 13217 | guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29); | |
| 16364 |
1/2✓ Branch 0 taken 13217 times.
✗ Branch 1 not taken.
|
13217 | guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31); |
| 16365 | 13217 | } | |
| 16366 | else | ||
| 16367 | { | ||
| 16368 | 11574 | guys.spr(i)->x = circle_x; | |
| 16369 | 11574 | guys.spr(i)->y = circle_y; | |
| 16370 | } | ||
| 16371 | |||
| 16372 | 24791 | temp_x=circle_x; | |
| 16373 | 24791 | temp_y=circle_y; | |
| 16374 | } | ||
| 16375 | |||
| 16376 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 16377 | 30119 | double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x)); | |
| 16378 | |||
| 16379 |
4/4✓ Branch 0 taken 5749 times.
✓ Branch 1 taken 24370 times.
✓ Branch 2 taken 1999 times.
✓ Branch 3 taken 3750 times.
|
30119 | if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) |
| 16380 | { | ||
| 16381 | 3750 | guys.spr(i)->dir=l_down; | |
| 16382 | 3750 | } | |
| 16383 |
4/4✓ Branch 0 taken 5813 times.
✓ Branch 1 taken 20556 times.
✓ Branch 2 taken 1999 times.
✓ Branch 3 taken 3814 times.
|
26369 | else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8))) |
| 16384 | { | ||
| 16385 | 3814 | guys.spr(i)->dir=left; | |
| 16386 | 3814 | } | |
| 16387 |
4/4✓ Branch 0 taken 5738 times.
✓ Branch 1 taken 16817 times.
✓ Branch 2 taken 1999 times.
✓ Branch 3 taken 3739 times.
|
22555 | else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8))) |
| 16388 | { | ||
| 16389 | 3739 | guys.spr(i)->dir=l_up; | |
| 16390 | 3739 | } | |
| 16391 |
4/4✓ Branch 0 taken 5788 times.
✓ Branch 1 taken 13028 times.
✓ Branch 2 taken 1999 times.
✓ Branch 3 taken 3789 times.
|
18816 | else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8))) |
| 16392 | { | ||
| 16393 | 3789 | guys.spr(i)->dir=up; | |
| 16394 | 3789 | } | |
| 16395 |
4/4✓ Branch 0 taken 5730 times.
✓ Branch 1 taken 9297 times.
✓ Branch 2 taken 1999 times.
✓ Branch 3 taken 3731 times.
|
15027 | else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8))) |
| 16396 | { | ||
| 16397 | 3731 | guys.spr(i)->dir=r_up; | |
| 16398 | 3731 | } | |
| 16399 |
4/4✓ Branch 0 taken 5759 times.
✓ Branch 1 taken 5537 times.
✓ Branch 2 taken 1999 times.
✓ Branch 3 taken 3760 times.
|
11296 | else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8))) |
| 16400 | { | ||
| 16401 | 3760 | guys.spr(i)->dir=right; | |
| 16402 | 3760 | } | |
| 16403 |
4/4✓ Branch 0 taken 5726 times.
✓ Branch 1 taken 1810 times.
✓ Branch 2 taken 1999 times.
✓ Branch 3 taken 3727 times.
|
7536 | else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8))) |
| 16404 | { | ||
| 16405 | 3727 | guys.spr(i)->dir=r_down; | |
| 16406 | 3727 | } | |
| 16407 | else | ||
| 16408 | { | ||
| 16409 | 3809 | guys.spr(i)->dir=down; | |
| 16410 | } | ||
| 16411 | |||
| 16412 | 30119 | guys.spr(i)->x += x; | |
| 16413 | 30119 | guys.spr(i)->y += y; | |
| 16414 | } | ||
| 16415 | 30147 | } | |
| 16416 | |||
| 16417 |
2/22✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7998 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
7998 | if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt))) |
| 16418 | { | ||
| 16419 | ✗ | int timeneeded = 48; | |
| 16420 | ✗ | int patbreath = (zc_oldrand()%50+50); | |
| 16421 | ✗ | if ((patbreath % 4) == 0) ++patbreath; | |
| 16422 | ✗ | if (dmisc28 == patratBREATH) | |
| 16423 | { | ||
| 16424 | ✗ | timeneeded = 48 + patbreath; | |
| 16425 | ✗ | } | |
| 16426 | ✗ | if (dmisc28 == patratSTREAM) | |
| 16427 | { | ||
| 16428 | ✗ | timeneeded = 48 + 96; | |
| 16429 | ✗ | } | |
| 16430 | ✗ | if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance | |
| 16431 | ✗ | (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance | |
| 16432 | ✗ | || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) | |
| 16433 | ✗ | || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))))) | |
| 16434 | ✗ | && (clk6 >= 0) //if not in the middle of firing... | |
| 16435 | ✗ | && clk6 >= dmisc19) //if over the set cooldown between shots... | |
| 16436 | ✗ | && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack. | |
| 16437 | { | ||
| 16438 | ✗ | switch(dmisc28) | |
| 16439 | { | ||
| 16440 | case patratSTREAM: | ||
| 16441 | { | ||
| 16442 | ✗ | clk7 = 97; | |
| 16443 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48; | |
| 16444 | ✗ | else clk6 = 0; | |
| 16445 | ✗ | break; | |
| 16446 | } | ||
| 16447 | case patratBREATH: | ||
| 16448 | { | ||
| 16449 | ✗ | clk7 = patbreath; | |
| 16450 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48; | |
| 16451 | ✗ | else clk6 = 0; | |
| 16452 | ✗ | break; | |
| 16453 | } | ||
| 16454 | default: | ||
| 16455 | { | ||
| 16456 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) | |
| 16457 | { | ||
| 16458 | ✗ | clk6 = -48; | |
| 16459 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16; | |
| 16460 | ✗ | } | |
| 16461 | else | ||
| 16462 | { | ||
| 16463 | ✗ | clk6 = 0; | |
| 16464 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = 16; | |
| 16465 | ✗ | FirePatraWeapon(); | |
| 16466 | } | ||
| 16467 | ✗ | break; | |
| 16468 | } | ||
| 16469 | } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x))); | ||
| 16470 | ✗ | } | |
| 16471 | ✗ | if (clk6 < 0) | |
| 16472 | { | ||
| 16473 | ✗ | switch(dmisc28) | |
| 16474 | { | ||
| 16475 | case patratSTREAM: | ||
| 16476 | { | ||
| 16477 | ✗ | if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon(); | |
| 16478 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16; | |
| 16479 | ✗ | break; | |
| 16480 | } | ||
| 16481 | case patratBREATH: | ||
| 16482 | { | ||
| 16483 | ✗ | if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon(); | |
| 16484 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16; | |
| 16485 | ✗ | break; | |
| 16486 | } | ||
| 16487 | default: | ||
| 16488 | { | ||
| 16489 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16) | |
| 16490 | { | ||
| 16491 | ✗ | FirePatraWeapon(); | |
| 16492 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16; | |
| 16493 | ✗ | } | |
| 16494 | ✗ | break; | |
| 16495 | } | ||
| 16496 | } | ||
| 16497 | ✗ | } | |
| 16498 | ✗ | } | |
| 16499 | |||
| 16500 | 7998 | int randattempts = 0; | |
| 16501 | 7998 | int randeye = 0; | |
| 16502 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | if (flycnt2 > 0) |
| 16503 | { | ||
| 16504 | ✗ | do | |
| 16505 | { | ||
| 16506 | ✗ | randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0); | |
| 16507 | ✗ | randeye += (index + flycnt + 1); | |
| 16508 | ✗ | ++randattempts; | |
| 16509 | ✗ | } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10); | |
| 16510 | ✗ | } | |
| 16511 | 7998 | bool dofire = false; | |
| 16512 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | if (dmisc20) |
| 16513 | { | ||
| 16514 | ✗ | if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) || | |
| 16515 | ✗ | (dmisc18 == 0 && !(zc_oldrand()&127)) || | |
| 16516 | ✗ | (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4) | |
| 16517 | ✗ | || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2)) | |
| 16518 | ✗ | || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4)))) | |
| 16519 | { | ||
| 16520 | ✗ | if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) | |
| 16521 | { | ||
| 16522 | ✗ | if (clk5 >= dmisc19) | |
| 16523 | { | ||
| 16524 | ✗ | if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && | |
| 16525 | ✗ | (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) || | |
| 16526 | ✗ | (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) || | |
| 16527 | ✗ | (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))) | |
| 16528 | ✗ | || dmisc18 == -1) | |
| 16529 | ✗ | dofire = true; | |
| 16530 | ✗ | } | |
| 16531 | ✗ | } | |
| 16532 | ✗ | } | |
| 16533 | ✗ | } | |
| 16534 |
1/2✓ Branch 0 taken 7998 times.
✗ Branch 1 not taken.
|
7998 | if(flycnt2) |
| 16535 | { | ||
| 16536 | ✗ | for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring | |
| 16537 | { | ||
| 16538 | ✗ | if(!adjusted) | |
| 16539 | { | ||
| 16540 | ✗ | ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult(); | |
| 16541 | |||
| 16542 | ✗ | if(get_qr(qr_NEWENEMYTILES)) | |
| 16543 | { | ||
| 16544 | ✗ | if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS)) | |
| 16545 | { | ||
| 16546 | ✗ | switch(dmisc5) | |
| 16547 | { | ||
| 16548 | // Center eye shoots projectiles; make room for its firing tiles | ||
| 16549 | case 1: | ||
| 16550 | case 3: | ||
| 16551 | ✗ | ((enemy*)guys.spr(i))->o_tile=d->e_tile+120; | |
| 16552 | ✗ | break; | |
| 16553 | |||
| 16554 | // Center eyes does not shoot; use tiles two rows below for inner eyes. | ||
| 16555 | default: | ||
| 16556 | case 2: | ||
| 16557 | ✗ | ((enemy*)guys.spr(i))->o_tile=d->e_tile+40; | |
| 16558 | ✗ | break; | |
| 16559 | } | ||
| 16560 | ✗ | } | |
| 16561 | ✗ | else ((enemy*)guys.spr(i))->o_tile = d->s_tile; | |
| 16562 | ✗ | } | |
| 16563 | else | ||
| 16564 | { | ||
| 16565 | ✗ | ((enemy*)guys.spr(i))->o_tile=o_tile+1; | |
| 16566 | } | ||
| 16567 | |||
| 16568 | ✗ | ((enemy*)guys.spr(i))->cs=dmisc9; | |
| 16569 | ✗ | if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27; | |
| 16570 | ✗ | } | |
| 16571 | |||
| 16572 | ✗ | if(flycnt>0) | |
| 16573 | { | ||
| 16574 | ✗ | ((enemy*)guys.spr(i))->superman=true; | |
| 16575 | ✗ | } | |
| 16576 | else | ||
| 16577 | { | ||
| 16578 | ✗ | ((enemy*)guys.spr(i))->superman=false; | |
| 16579 | } | ||
| 16580 | |||
| 16581 | ✗ | if(((enemy*)guys.spr(i))->hp <= 0) | |
| 16582 | { | ||
| 16583 | ✗ | for(int32_t j=i; j<index+flycnt+flycnt2; j++) | |
| 16584 | { | ||
| 16585 | ✗ | guys.swap(j,j+1); | |
| 16586 | ✗ | } | |
| 16587 | |||
| 16588 | ✗ | if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100); | |
| 16589 | ✗ | } | |
| 16590 | else | ||
| 16591 | { | ||
| 16592 | ✗ | int32_t pos2 = ((enemy*)guys.spr(i))->misc; | |
| 16593 | ✗ | double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize)); | |
| 16594 | |||
| 16595 | ✗ | if(dmisc4==0) | |
| 16596 | { | ||
| 16597 | ✗ | if(loopcnt>0) | |
| 16598 | { | ||
| 16599 | ✗ | guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30)); | |
| 16600 | ✗ | guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30)); | |
| 16601 | ✗ | } | |
| 16602 | else | ||
| 16603 | { | ||
| 16604 | ✗ | guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30); | |
| 16605 | ✗ | guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30); | |
| 16606 | } | ||
| 16607 | |||
| 16608 | ✗ | temp_x=guys.spr(i)->x; | |
| 16609 | ✗ | temp_y=guys.spr(i)->y; | |
| 16610 | ✗ | } | |
| 16611 | else | ||
| 16612 | { | ||
| 16613 | ✗ | circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30); | |
| 16614 | ✗ | circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30); | |
| 16615 | |||
| 16616 | ✗ | if(loopcnt>0) | |
| 16617 | { | ||
| 16618 | ✗ | guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30); | |
| 16619 | ✗ | guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32); | |
| 16620 | ✗ | } | |
| 16621 | else | ||
| 16622 | { | ||
| 16623 | ✗ | guys.spr(i)->x = circle_x; | |
| 16624 | ✗ | guys.spr(i)->y = circle_y; | |
| 16625 | } | ||
| 16626 | |||
| 16627 | ✗ | temp_x=circle_x; | |
| 16628 | ✗ | temp_y=circle_y; | |
| 16629 | } | ||
| 16630 | |||
| 16631 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 16632 | ✗ | double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x)); | |
| 16633 | |||
| 16634 | ✗ | if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) | |
| 16635 | { | ||
| 16636 | ✗ | guys.spr(i)->dir=l_down; | |
| 16637 | ✗ | } | |
| 16638 | ✗ | else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8))) | |
| 16639 | { | ||
| 16640 | ✗ | guys.spr(i)->dir=left; | |
| 16641 | ✗ | } | |
| 16642 | ✗ | else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8))) | |
| 16643 | { | ||
| 16644 | ✗ | guys.spr(i)->dir=l_up; | |
| 16645 | ✗ | } | |
| 16646 | ✗ | else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8))) | |
| 16647 | { | ||
| 16648 | ✗ | guys.spr(i)->dir=up; | |
| 16649 | ✗ | } | |
| 16650 | ✗ | else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8))) | |
| 16651 | { | ||
| 16652 | ✗ | guys.spr(i)->dir=r_up; | |
| 16653 | ✗ | } | |
| 16654 | ✗ | else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8))) | |
| 16655 | { | ||
| 16656 | ✗ | guys.spr(i)->dir=right; | |
| 16657 | ✗ | } | |
| 16658 | ✗ | else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8))) | |
| 16659 | { | ||
| 16660 | ✗ | guys.spr(i)->dir=r_down; | |
| 16661 | ✗ | } | |
| 16662 | else | ||
| 16663 | { | ||
| 16664 | ✗ | guys.spr(i)->dir=down; | |
| 16665 | } | ||
| 16666 | |||
| 16667 | ✗ | guys.spr(i)->x += x; | |
| 16668 | ✗ | guys.spr(i)->y = y-guys.spr(i)->y; | |
| 16669 | |||
| 16670 | ✗ | if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3)) | |
| 16671 | { | ||
| 16672 | /* | ||
| 16673 | if(!(zc_oldrand()&127)) | ||
| 16674 | { | ||
| 16675 | addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID()); | ||
| 16676 | sfx(wpnsfx(wpn),pan(int32_t(x))); | ||
| 16677 | } | ||
| 16678 | */ | ||
| 16679 | ✗ | if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3)) | |
| 16680 | { | ||
| 16681 | ✗ | if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5; | |
| 16682 | ✗ | if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS)) | |
| 16683 | { | ||
| 16684 | ✗ | if (dmisc5 == 3) | |
| 16685 | { | ||
| 16686 | ✗ | if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120; | |
| 16687 | ✗ | else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200; | |
| 16688 | ✗ | else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160; | |
| 16689 | ✗ | else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120; | |
| 16690 | ✗ | } | |
| 16691 | else | ||
| 16692 | { | ||
| 16693 | ✗ | if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40; | |
| 16694 | ✗ | else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120; | |
| 16695 | ✗ | else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80; | |
| 16696 | ✗ | else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40; | |
| 16697 | } | ||
| 16698 | ✗ | } | |
| 16699 | else | ||
| 16700 | { | ||
| 16701 | ✗ | if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile; | |
| 16702 | ✗ | else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80; | |
| 16703 | ✗ | else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40; | |
| 16704 | ✗ | else ((esPatra*)guys.spr(i))->o_tile=d->s_tile; | |
| 16705 | } | ||
| 16706 | ✗ | } | |
| 16707 | ✗ | else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5; | |
| 16708 | ✗ | if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4; | |
| 16709 | ✗ | if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman)) | |
| 16710 | { | ||
| 16711 | ✗ | switch(dmisc20) //Patra Attack Patterns | |
| 16712 | { | ||
| 16713 | case 4: //Single one rapidfires | ||
| 16714 | { | ||
| 16715 | ✗ | if (dofire && i == randeye) | |
| 16716 | { | ||
| 16717 | ✗ | ((esPatra*)guys.spr(i))->clk5 = -16; | |
| 16718 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48; | |
| 16719 | ✗ | ((esPatra*)guys.spr(i))->clk4 = 96; | |
| 16720 | ✗ | clk5 = -3; | |
| 16721 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16; | |
| 16722 | ✗ | } | |
| 16723 | ✗ | if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0) | |
| 16724 | { | ||
| 16725 | ✗ | addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez); | |
| 16726 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16727 | ✗ | } | |
| 16728 | ✗ | break; | |
| 16729 | } | ||
| 16730 | case 3: //Ring | ||
| 16731 | { | ||
| 16732 | ✗ | if (dofire) | |
| 16733 | { | ||
| 16734 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) | |
| 16735 | { | ||
| 16736 | ✗ | ((esPatra*)guys.spr(i))->clk5 = -48; | |
| 16737 | ✗ | clk5 = -48; | |
| 16738 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = 64; | |
| 16739 | ✗ | } | |
| 16740 | else | ||
| 16741 | { | ||
| 16742 | ✗ | addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez); | |
| 16743 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16744 | ✗ | int32_t m=Ewpns.Count()-1; | |
| 16745 | ✗ | weapon *ew = (weapon*)(Ewpns.spr(m)); | |
| 16746 | |||
| 16747 | ✗ | ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x))); | |
| 16748 | ✗ | ((esPatra*)guys.spr(i))->clk5 = 0; | |
| 16749 | ✗ | clk5 = 0; | |
| 16750 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = 16; | |
| 16751 | } | ||
| 16752 | ✗ | } | |
| 16753 | ✗ | if (((esPatra*)guys.spr(i))->clk5 == -16) | |
| 16754 | { | ||
| 16755 | ✗ | addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez); | |
| 16756 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16757 | ✗ | int32_t m=Ewpns.Count()-1; | |
| 16758 | ✗ | weapon *ew = (weapon*)(Ewpns.spr(m)); | |
| 16759 | |||
| 16760 | ✗ | ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x))); | |
| 16761 | ✗ | } | |
| 16762 | ✗ | break; | |
| 16763 | } | ||
| 16764 | case 2: //one after another | ||
| 16765 | { | ||
| 16766 | ✗ | if (dofire) | |
| 16767 | { | ||
| 16768 | ✗ | ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1))); | |
| 16769 | ✗ | clk5 = -48 - (12*flycnt2); | |
| 16770 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16; | |
| 16771 | ✗ | } | |
| 16772 | ✗ | if (((esPatra*)guys.spr(i))->clk5 == -16) | |
| 16773 | { | ||
| 16774 | ✗ | addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez); | |
| 16775 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16776 | ✗ | } | |
| 16777 | ✗ | break; | |
| 16778 | } | ||
| 16779 | case 1: //random one eye | ||
| 16780 | { | ||
| 16781 | ✗ | if (dofire && i == randeye) | |
| 16782 | { | ||
| 16783 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) | |
| 16784 | { | ||
| 16785 | ✗ | ((esPatra*)guys.spr(i))->clk5 = -48; | |
| 16786 | ✗ | clk5 = -48; | |
| 16787 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = 64; | |
| 16788 | ✗ | } | |
| 16789 | else | ||
| 16790 | { | ||
| 16791 | ✗ | addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez); | |
| 16792 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16793 | ✗ | ((esPatra*)guys.spr(i))->clk5 = 0; | |
| 16794 | ✗ | clk5 = 0; | |
| 16795 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = 16; | |
| 16796 | } | ||
| 16797 | ✗ | } | |
| 16798 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16) | |
| 16799 | { | ||
| 16800 | ✗ | addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez); | |
| 16801 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16802 | ✗ | } | |
| 16803 | ✗ | break; | |
| 16804 | } | ||
| 16805 | default: //old behavior, all eyes can fire any time | ||
| 16806 | { | ||
| 16807 | ✗ | if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) || | |
| 16808 | ✗ | (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) | |
| 16809 | ✗ | && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && | |
| 16810 | ✗ | (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))) | |
| 16811 | { | ||
| 16812 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) | |
| 16813 | { | ||
| 16814 | ✗ | ((esPatra*)guys.spr(i))->clk5 = -48; | |
| 16815 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = 64; | |
| 16816 | ✗ | } | |
| 16817 | else | ||
| 16818 | { | ||
| 16819 | ✗ | addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez); | |
| 16820 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16821 | ✗ | ((esPatra*)guys.spr(i))->clk5 = 0; | |
| 16822 | ✗ | if (editorflags & ENEMY_FLAG6) clk4 = 16; | |
| 16823 | } | ||
| 16824 | ✗ | } | |
| 16825 | ✗ | if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16) | |
| 16826 | { | ||
| 16827 | ✗ | addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez); | |
| 16828 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16829 | ✗ | } | |
| 16830 | ✗ | break; | |
| 16831 | } | ||
| 16832 | } | ||
| 16833 | ✗ | } | |
| 16834 | ✗ | } | |
| 16835 | |||
| 16836 | } | ||
| 16837 | ✗ | } | |
| 16838 | ✗ | } | |
| 16839 | |||
| 16840 | 7998 | adjusted=true; | |
| 16841 | 7998 | return enemy::animate(index); | |
| 16842 | 8070 | } | |
| 16843 | |||
| 16844 | ✗ | void ePatra::FirePatraWeapon() | |
| 16845 | { //.707 | ||
| 16846 | ✗ | int32_t xoff = 0; | |
| 16847 | ✗ | int32_t yoff = 0; | |
| 16848 | ✗ | if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH ) | |
| 16849 | { | ||
| 16850 | ✗ | xoff += (hit_width/2)-8; | |
| 16851 | //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff); | ||
| 16852 | ✗ | } | |
| 16853 | ✗ | if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT ) | |
| 16854 | { | ||
| 16855 | ✗ | yoff += (hit_height/2)-8; | |
| 16856 | //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff); | ||
| 16857 | ✗ | } | |
| 16858 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16859 | ✗ | switch (dmisc28) | |
| 16860 | { | ||
| 16861 | case patrat8SHOT: //Fire Wizzrobe | ||
| 16862 | case patrat4SHOTDIAG: | ||
| 16863 | case patrat4SHOTRAND: | ||
| 16864 | ✗ | if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one. | |
| 16865 | { | ||
| 16866 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false)); | |
| 16867 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 16868 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 16869 | ✗ | if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason. | |
| 16870 | |||
| 16871 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false)); | |
| 16872 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 16873 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 16874 | ✗ | if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason. | |
| 16875 | |||
| 16876 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false)); | |
| 16877 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 16878 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 16879 | ✗ | if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason. | |
| 16880 | |||
| 16881 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false)); | |
| 16882 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 16883 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 16884 | ✗ | if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason. | |
| 16885 | |||
| 16886 | ✗ | if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break; | |
| 16887 | ✗ | } | |
| 16888 | |||
| 16889 | [[fallthrough]]; | ||
| 16890 | case patrat4SHOTCARD: //Stalfos 3 | ||
| 16891 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false)); | |
| 16892 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 16893 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 16894 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false)); | |
| 16895 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 16896 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 16897 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false)); | |
| 16898 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 16899 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 16900 | ✗ | Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false)); | |
| 16901 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; | |
| 16902 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits | |
| 16903 | ✗ | break; | |
| 16904 | |||
| 16905 | default: | ||
| 16906 | ✗ | addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez); | |
| 16907 | ✗ | if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI; | |
| 16908 | ✗ | double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle; | |
| 16909 | ✗ | if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2; | |
| 16910 | ✗ | if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST) | |
| 16911 | { | ||
| 16912 | ✗ | addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez); | |
| 16913 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761; | |
| 16914 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180; | |
| 16915 | ✗ | if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2; | |
| 16916 | ✗ | addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez); | |
| 16917 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761; | |
| 16918 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180; | |
| 16919 | ✗ | if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2; | |
| 16920 | ✗ | if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST) | |
| 16921 | { | ||
| 16922 | ✗ | addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez); | |
| 16923 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816; | |
| 16924 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142; | |
| 16925 | ✗ | if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2; | |
| 16926 | ✗ | addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez); | |
| 16927 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816; | |
| 16928 | ✗ | ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142; | |
| 16929 | ✗ | if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2; | |
| 16930 | ✗ | } | |
| 16931 | ✗ | } | |
| 16932 | ✗ | break; | |
| 16933 | |||
| 16934 | } | ||
| 16935 | ✗ | sfx(wpnsfx(wpn),pan(int32_t(x))); | |
| 16936 | //+0.46364761 | ||
| 16937 | //11.80 | ||
| 16938 | ✗ | } | |
| 16939 | |||
| 16940 | 16140 | void ePatra::draw(BITMAP *dest) | |
| 16941 | { | ||
| 16942 | 16140 | tile=o_tile; | |
| 16943 | 16140 | update_enemy_frame(); | |
| 16944 | 16140 | enemy::draw(dest); | |
| 16945 | 16140 | } | |
| 16946 | |||
| 16947 | ✗ | int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef) | |
| 16948 | { | ||
| 16949 | ✗ | int32_t ret = enemy::defend(wpnId, power, edef); | |
| 16950 | |||
| 16951 | ✗ | if(ret < 0 && (flycnt||flycnt2)) | |
| 16952 | ✗ | return 0; | |
| 16953 | |||
| 16954 | ✗ | return ret; | |
| 16955 | ✗ | } | |
| 16956 | |||
| 16957 | 9 | int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) | |
| 16958 | { | ||
| 16959 | 9 | int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable); | |
| 16960 | |||
| 16961 |
3/6✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
|
9 | if(ret < 0 && (flycnt||flycnt2)) |
| 16962 | ✗ | return 0; | |
| 16963 | |||
| 16964 | 9 | return ret; | |
| 16965 | 9 | } | |
| 16966 | |||
| 16967 | 64 | esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt) | |
| 16968 | 32 | { | |
| 16969 | //cs=8; | ||
| 16970 | 32 | item_set=0; | |
| 16971 | 32 | misc=clk; | |
| 16972 | 32 | clk4 = 0; | |
| 16973 | 32 | clk5 = 0; | |
| 16974 | 32 | clk = -((misc*21)>>1)-1; | |
| 16975 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
|
32 | yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); |
| 16976 | 32 | hit_width=12; | |
| 16977 | 32 | hit_height=12; | |
| 16978 | 32 | hxofs=2; | |
| 16979 | 32 | hyofs=2; | |
| 16980 | 32 | extend = 0; | |
| 16981 | 32 | txsz = 1; | |
| 16982 | 32 | tysz = 1; | |
| 16983 | /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff. | ||
| 16984 | enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID()); | ||
| 16985 | int32_t prntSIZEflags = prntenemy->SIZEflags; | ||
| 16986 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. | ||
| 16987 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 16988 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 16989 | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; } | ||
| 16990 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz; | ||
| 16991 | else | ||
| 16992 | hxsz=12; | ||
| 16993 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz; | ||
| 16994 | else | ||
| 16995 | hysz=12; | ||
| 16996 | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz; | ||
| 16997 | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs; | ||
| 16998 | else | ||
| 16999 | hxofs=2; | ||
| 17000 | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs; | ||
| 17001 | else hyofs=2; | ||
| 17002 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 17003 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs; | ||
| 17004 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) | ||
| 17005 | { | ||
| 17006 | yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z | ||
| 17007 | } | ||
| 17008 | |||
| 17009 | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs; | ||
| 17010 | */ | ||
| 17011 | 32 | mainguy=count_enemy=false; | |
| 17012 | 32 | bgsfx=-1; | |
| 17013 | //o_tile=0; | ||
| 17014 | 32 | flags &= (~guy_neverret); | |
| 17015 | 32 | deadsfx = WAV_EDEAD; | |
| 17016 | 32 | hitsfx = WAV_EHIT; | |
| 17017 | 32 | isCore = false; | |
| 17018 | 32 | } | |
| 17019 | |||
| 17020 | 30742 | bool esPatra::animate(int32_t index) | |
| 17021 | { | ||
| 17022 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 30742 times.
|
30742 | if(switch_hooked) return enemy::animate(index); |
| 17023 |
2/2✓ Branch 0 taken 576 times.
✓ Branch 1 taken 30166 times.
|
30742 | if(dying) |
| 17024 | 576 | return Dead(index); | |
| 17025 | |||
| 17026 | 30166 | return enemy::animate(index); | |
| 17027 | 30742 | } | |
| 17028 | |||
| 17029 | 61484 | void esPatra::draw(BITMAP *dest) | |
| 17030 | { | ||
| 17031 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61484 times.
|
61484 | if(get_qr(qr_NEWENEMYTILES)) |
| 17032 | { | ||
| 17033 | ✗ | tile = o_tile+(clk&3); | |
| 17034 | |||
| 17035 | ✗ | switch(dir) //directions get screwed up after 8. *shrug* | |
| 17036 | { | ||
| 17037 | case up: //u | ||
| 17038 | ✗ | flip=0; | |
| 17039 | ✗ | break; | |
| 17040 | |||
| 17041 | case down: //d | ||
| 17042 | ✗ | flip=0; | |
| 17043 | ✗ | tile+=4; | |
| 17044 | ✗ | break; | |
| 17045 | |||
| 17046 | case left: //l | ||
| 17047 | ✗ | flip=0; | |
| 17048 | ✗ | tile+=8; | |
| 17049 | ✗ | break; | |
| 17050 | |||
| 17051 | case right: //r | ||
| 17052 | ✗ | flip=0; | |
| 17053 | ✗ | tile+=12; | |
| 17054 | ✗ | break; | |
| 17055 | |||
| 17056 | case l_up: //ul | ||
| 17057 | ✗ | flip=0; | |
| 17058 | ✗ | tile+=20; | |
| 17059 | ✗ | break; | |
| 17060 | |||
| 17061 | case r_up: //ur | ||
| 17062 | ✗ | flip=0; | |
| 17063 | ✗ | tile+=24; | |
| 17064 | ✗ | break; | |
| 17065 | |||
| 17066 | case l_down: //dl | ||
| 17067 | ✗ | flip=0; | |
| 17068 | ✗ | tile+=28; | |
| 17069 | ✗ | break; | |
| 17070 | |||
| 17071 | case r_down: //dr | ||
| 17072 | ✗ | flip=0; | |
| 17073 | ✗ | tile+=32; | |
| 17074 | ✗ | break; | |
| 17075 | } | ||
| 17076 | ✗ | } | |
| 17077 | else | ||
| 17078 | { | ||
| 17079 | 61484 | tile = o_tile+((clk&2)>>1); | |
| 17080 | } | ||
| 17081 | |||
| 17082 |
2/2✓ Branch 0 taken 2280 times.
✓ Branch 1 taken 59204 times.
|
61484 | if(clk>=0) |
| 17083 | 59204 | enemy::draw(dest); | |
| 17084 | 61484 | } | |
| 17085 | |||
| 17086 | |||
| 17087 | ✗ | ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk) | |
| 17088 | ✗ | { | |
| 17089 | ✗ | adjusted=false; | |
| 17090 | ✗ | dir=(zc_oldrand()&7)+8; | |
| 17091 | ✗ | step=0.25; | |
| 17092 | ✗ | clk4 = 0; | |
| 17093 | ✗ | clk5 = 0; | |
| 17094 | //flycnt=6; flycnt2=0; | ||
| 17095 | ✗ | flycnt=dmisc1; | |
| 17096 | ✗ | flycnt2=0; // PatraBS doesn't have inner rings! | |
| 17097 | ✗ | loopcnt=0; | |
| 17098 | |||
| 17099 | ✗ | SIZEflags = d->SIZEflags; | |
| 17100 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. | |
| 17101 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 17102 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 17103 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; } | |
| 17104 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz; | |
| 17105 | ✗ | else hit_width = 32; | |
| 17106 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz; | |
| 17107 | ✗ | if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz; | |
| 17108 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs; | |
| 17109 | ✗ | else hxofs=-8; | |
| 17110 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs; | |
| 17111 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 17112 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs; | |
| 17113 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) | |
| 17114 | { | ||
| 17115 | ✗ | yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z | |
| 17116 | ✗ | yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z | |
| 17117 | ✗ | } | |
| 17118 | |||
| 17119 | ✗ | if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs; | |
| 17120 | |||
| 17121 | ✗ | if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0! | |
| 17122 | |||
| 17123 | //nets+4480; | ||
| 17124 | ✗ | } | |
| 17125 | |||
| 17126 | ✗ | bool ePatraBS::animate(int32_t index) | |
| 17127 | { | ||
| 17128 | ✗ | if(switch_hooked) return enemy::animate(index); | |
| 17129 | ✗ | if(dying) | |
| 17130 | ✗ | return Dead(index); | |
| 17131 | |||
| 17132 | ✗ | if(clk==0) | |
| 17133 | { | ||
| 17134 | ✗ | removearmos(x,y,ffcactivated); | |
| 17135 | ✗ | } | |
| 17136 | |||
| 17137 | ✗ | variable_walk_8(rate,homing,hrate,spw_floater); | |
| 17138 | |||
| 17139 | ✗ | if(++clk2>90) | |
| 17140 | { | ||
| 17141 | ✗ | clk2=0; | |
| 17142 | |||
| 17143 | ✗ | if(loopcnt) | |
| 17144 | ✗ | --loopcnt; | |
| 17145 | else | ||
| 17146 | { | ||
| 17147 | ✗ | if((misc%dmisc6)==0) | |
| 17148 | ✗ | loopcnt=dmisc7; | |
| 17149 | } | ||
| 17150 | |||
| 17151 | ✗ | ++misc; | |
| 17152 | ✗ | } | |
| 17153 | |||
| 17154 | // double size=1;; | ||
| 17155 | ✗ | for(int32_t i=index+1; i<index+flycnt+1; i++) | |
| 17156 | { | ||
| 17157 | ✗ | if(!adjusted) | |
| 17158 | { | ||
| 17159 | ✗ | ((enemy*)guys.spr(i))->hp=dmisc3; | |
| 17160 | |||
| 17161 | ✗ | if(get_qr(qr_NEWENEMYTILES)) | |
| 17162 | { | ||
| 17163 | ✗ | ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8; | |
| 17164 | ✗ | } | |
| 17165 | else | ||
| 17166 | { | ||
| 17167 | ✗ | ((enemy*)guys.spr(i))->o_tile=o_tile+1; | |
| 17168 | } | ||
| 17169 | |||
| 17170 | ✗ | ((enemy*)guys.spr(i))->cs = dmisc9; | |
| 17171 | ✗ | } | |
| 17172 | |||
| 17173 | ✗ | if(((enemy*)guys.spr(i))->hp <= 0) | |
| 17174 | { | ||
| 17175 | ✗ | for(int32_t j=i; j<index+flycnt+flycnt2; j++) | |
| 17176 | { | ||
| 17177 | ✗ | guys.swap(j,j+1); | |
| 17178 | ✗ | } | |
| 17179 | |||
| 17180 | ✗ | --flycnt; | |
| 17181 | ✗ | } | |
| 17182 | else | ||
| 17183 | { | ||
| 17184 | ✗ | int32_t pos2 = ((enemy*)guys.spr(i))->misc; | |
| 17185 | ✗ | double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45; | |
| 17186 | ✗ | temp_x = zc::math::Cos(a2+PI/2)*45; | |
| 17187 | ✗ | temp_y = -zc::math::Sin(a2+PI/2)*45; | |
| 17188 | |||
| 17189 | ✗ | if(loopcnt>0) | |
| 17190 | { | ||
| 17191 | ✗ | guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45; | |
| 17192 | ✗ | guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5; | |
| 17193 | ✗ | } | |
| 17194 | else | ||
| 17195 | { | ||
| 17196 | ✗ | guys.spr(i)->x = temp_x; | |
| 17197 | ✗ | guys.spr(i)->y = temp_y; | |
| 17198 | } | ||
| 17199 | |||
| 17200 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 17201 | ✗ | double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x)); | |
| 17202 | |||
| 17203 | ✗ | if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) | |
| 17204 | { | ||
| 17205 | ✗ | guys.spr(i)->dir=l_down; | |
| 17206 | ✗ | } | |
| 17207 | ✗ | else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8))) | |
| 17208 | { | ||
| 17209 | ✗ | guys.spr(i)->dir=left; | |
| 17210 | ✗ | } | |
| 17211 | ✗ | else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8))) | |
| 17212 | { | ||
| 17213 | ✗ | guys.spr(i)->dir=l_up; | |
| 17214 | ✗ | } | |
| 17215 | ✗ | else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8))) | |
| 17216 | { | ||
| 17217 | ✗ | guys.spr(i)->dir=up; | |
| 17218 | ✗ | } | |
| 17219 | ✗ | else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8))) | |
| 17220 | { | ||
| 17221 | ✗ | guys.spr(i)->dir=r_up; | |
| 17222 | ✗ | } | |
| 17223 | ✗ | else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8))) | |
| 17224 | { | ||
| 17225 | ✗ | guys.spr(i)->dir=right; | |
| 17226 | ✗ | } | |
| 17227 | ✗ | else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8))) | |
| 17228 | { | ||
| 17229 | ✗ | guys.spr(i)->dir=r_down; | |
| 17230 | ✗ | } | |
| 17231 | else | ||
| 17232 | { | ||
| 17233 | ✗ | guys.spr(i)->dir=down; | |
| 17234 | } | ||
| 17235 | |||
| 17236 | ✗ | guys.spr(i)->x += x; | |
| 17237 | ✗ | guys.spr(i)->y += y; | |
| 17238 | } | ||
| 17239 | ✗ | } | |
| 17240 | |||
| 17241 | ✗ | adjusted=true; | |
| 17242 | ✗ | return enemy::animate(index); | |
| 17243 | ✗ | } | |
| 17244 | |||
| 17245 | ✗ | void ePatraBS::draw(BITMAP *dest) | |
| 17246 | { | ||
| 17247 | ✗ | tile=o_tile; | |
| 17248 | |||
| 17249 | ✗ | if(get_qr(qr_NEWENEMYTILES)) | |
| 17250 | { | ||
| 17251 | double _MSVC2022_tmp1, _MSVC2022_tmp2; | ||
| 17252 | ✗ | double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x)); | |
| 17253 | |||
| 17254 | ✗ | if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8))) | |
| 17255 | { | ||
| 17256 | ✗ | lookat=l_down; | |
| 17257 | ✗ | } | |
| 17258 | ✗ | else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8))) | |
| 17259 | { | ||
| 17260 | ✗ | lookat=down; | |
| 17261 | ✗ | } | |
| 17262 | ✗ | else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8))) | |
| 17263 | { | ||
| 17264 | ✗ | lookat=r_down; | |
| 17265 | ✗ | } | |
| 17266 | ✗ | else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8))) | |
| 17267 | { | ||
| 17268 | ✗ | lookat=right; | |
| 17269 | ✗ | } | |
| 17270 | ✗ | else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8))) | |
| 17271 | { | ||
| 17272 | ✗ | lookat=r_up; | |
| 17273 | ✗ | } | |
| 17274 | ✗ | else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8))) | |
| 17275 | { | ||
| 17276 | ✗ | lookat=up; | |
| 17277 | ✗ | } | |
| 17278 | ✗ | else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8))) | |
| 17279 | { | ||
| 17280 | ✗ | lookat=l_up; | |
| 17281 | ✗ | } | |
| 17282 | else | ||
| 17283 | { | ||
| 17284 | ✗ | lookat=left; | |
| 17285 | } | ||
| 17286 | |||
| 17287 | ✗ | switch(lookat) //directions get screwed up after 8. *shrug* | |
| 17288 | { | ||
| 17289 | case up: //u | ||
| 17290 | ✗ | flip=0; | |
| 17291 | ✗ | break; | |
| 17292 | |||
| 17293 | case down: //d | ||
| 17294 | ✗ | flip=0; | |
| 17295 | ✗ | tile+=8; | |
| 17296 | ✗ | break; | |
| 17297 | |||
| 17298 | case left: //l | ||
| 17299 | ✗ | flip=0; | |
| 17300 | ✗ | tile+=40; | |
| 17301 | ✗ | break; | |
| 17302 | |||
| 17303 | case right: //r | ||
| 17304 | ✗ | flip=0; | |
| 17305 | ✗ | tile+=48; | |
| 17306 | ✗ | break; | |
| 17307 | |||
| 17308 | case l_up: //ul | ||
| 17309 | ✗ | flip=0; | |
| 17310 | ✗ | tile+=80; | |
| 17311 | ✗ | break; | |
| 17312 | |||
| 17313 | case r_up: //ur | ||
| 17314 | ✗ | flip=0; | |
| 17315 | ✗ | tile+=88; | |
| 17316 | ✗ | break; | |
| 17317 | |||
| 17318 | case l_down: //dl | ||
| 17319 | ✗ | flip=0; | |
| 17320 | ✗ | tile+=120; | |
| 17321 | ✗ | break; | |
| 17322 | |||
| 17323 | case r_down: //dr | ||
| 17324 | ✗ | flip=0; | |
| 17325 | ✗ | tile+=128; | |
| 17326 | ✗ | break; | |
| 17327 | } | ||
| 17328 | |||
| 17329 | ✗ | tile+=(2*(clk&3)); | |
| 17330 | ✗ | xofs-=8; | |
| 17331 | ✗ | yofs-=8; | |
| 17332 | ✗ | drawblock(dest,15); | |
| 17333 | ✗ | xofs+=8; | |
| 17334 | ✗ | yofs+=8; | |
| 17335 | ✗ | } | |
| 17336 | else | ||
| 17337 | { | ||
| 17338 | ✗ | flip=(clk&1); | |
| 17339 | ✗ | xofs-=8; | |
| 17340 | ✗ | yofs-=8; | |
| 17341 | ✗ | enemy::draw(dest); | |
| 17342 | ✗ | xofs+=16; | |
| 17343 | ✗ | enemy::draw(dest); | |
| 17344 | ✗ | yofs+=16; | |
| 17345 | ✗ | enemy::draw(dest); | |
| 17346 | ✗ | xofs-=16; | |
| 17347 | ✗ | enemy::draw(dest); | |
| 17348 | ✗ | xofs+=8; | |
| 17349 | ✗ | yofs-=8; | |
| 17350 | } | ||
| 17351 | ✗ | } | |
| 17352 | |||
| 17353 | ✗ | int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef) | |
| 17354 | { | ||
| 17355 | ✗ | int32_t ret = enemy::defend(wpnId, power, edef); | |
| 17356 | |||
| 17357 | ✗ | if(ret < 0 && (flycnt||flycnt2)) | |
| 17358 | ✗ | return 0; | |
| 17359 | |||
| 17360 | ✗ | return ret; | |
| 17361 | ✗ | } | |
| 17362 | |||
| 17363 | ✗ | int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) | |
| 17364 | { | ||
| 17365 | ✗ | int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable); | |
| 17366 | |||
| 17367 | ✗ | if(ret < 0 && (flycnt||flycnt2)) | |
| 17368 | ✗ | return 0; | |
| 17369 | |||
| 17370 | ✗ | return ret; | |
| 17371 | ✗ | } | |
| 17372 | |||
| 17373 | ✗ | esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt) | |
| 17374 | ✗ | { | |
| 17375 | //cs=csBOSS; | ||
| 17376 | ✗ | item_set=0; | |
| 17377 | ✗ | misc=clk; | |
| 17378 | ✗ | clk = -((misc*21)>>1)-1; | |
| 17379 | ✗ | clk4 = 0; | |
| 17380 | ✗ | clk5 = 0; | |
| 17381 | ✗ | enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID()); | |
| 17382 | ✗ | int32_t prntSIZEflags = prntenemy->SIZEflags; | |
| 17383 | ✗ | if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1. | |
| 17384 | //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z | ||
| 17385 | // al_trace("Enemy txsz:%i\n", txsz); | ||
| 17386 | ✗ | if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; } | |
| 17387 | ✗ | if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width; | |
| 17388 | ✗ | else hit_width=16; | |
| 17389 | ✗ | if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height; | |
| 17390 | ✗ | else hit_height=16; | |
| 17391 | ✗ | if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz; | |
| 17392 | ✗ | if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs; | |
| 17393 | ✗ | if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs; | |
| 17394 | ✗ | else hyofs=2; | |
| 17395 | // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs; | ||
| 17396 | ✗ | if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs; | |
| 17397 | ✗ | if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 ) | |
| 17398 | { | ||
| 17399 | ✗ | yofs = (int32_t)prntenemy->yofs; | |
| 17400 | ✗ | } | |
| 17401 | ✗ | else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset); | |
| 17402 | ✗ | if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs; | |
| 17403 | |||
| 17404 | ✗ | bgsfx=-1; | |
| 17405 | ✗ | mainguy=count_enemy=false; | |
| 17406 | ✗ | deadsfx = WAV_EDEAD; | |
| 17407 | ✗ | hitsfx = WAV_EHIT; | |
| 17408 | ✗ | flags &= ~guy_neverret; | |
| 17409 | ✗ | isCore = false; | |
| 17410 | ✗ | } | |
| 17411 | |||
| 17412 | ✗ | bool esPatraBS::animate(int32_t index) | |
| 17413 | { | ||
| 17414 | ✗ | if(switch_hooked) return enemy::animate(index); | |
| 17415 | ✗ | if(dying) | |
| 17416 | ✗ | return Dead(index); | |
| 17417 | |||
| 17418 | ✗ | return enemy::animate(index); | |
| 17419 | ✗ | } | |
| 17420 | |||
| 17421 | ✗ | void esPatraBS::draw(BITMAP *dest) | |
| 17422 | { | ||
| 17423 | ✗ | tile=o_tile; | |
| 17424 | |||
| 17425 | ✗ | if(get_qr(qr_NEWENEMYTILES)) | |
| 17426 | { | ||
| 17427 | ✗ | switch(dir) //directions get screwed up after 8. *shrug* | |
| 17428 | { | ||
| 17429 | case up: //u | ||
| 17430 | ✗ | flip=0; | |
| 17431 | ✗ | break; | |
| 17432 | |||
| 17433 | case down: //d | ||
| 17434 | ✗ | flip=0; | |
| 17435 | ✗ | tile+=4; | |
| 17436 | ✗ | break; | |
| 17437 | |||
| 17438 | case left: //l | ||
| 17439 | ✗ | flip=0; | |
| 17440 | ✗ | tile+=8; | |
| 17441 | ✗ | break; | |
| 17442 | |||
| 17443 | case right: //r | ||
| 17444 | ✗ | flip=0; | |
| 17445 | ✗ | tile+=12; | |
| 17446 | ✗ | break; | |
| 17447 | |||
| 17448 | case l_up: //ul | ||
| 17449 | ✗ | flip=0; | |
| 17450 | ✗ | tile+=20; | |
| 17451 | ✗ | break; | |
| 17452 | |||
| 17453 | case r_up: //ur | ||
| 17454 | ✗ | flip=0; | |
| 17455 | ✗ | tile+=24; | |
| 17456 | ✗ | break; | |
| 17457 | |||
| 17458 | case l_down: //dl | ||
| 17459 | ✗ | flip=0; | |
| 17460 | ✗ | tile+=28; | |
| 17461 | ✗ | break; | |
| 17462 | |||
| 17463 | case r_down: //dr | ||
| 17464 | ✗ | flip=0; | |
| 17465 | ✗ | tile+=32; | |
| 17466 | ✗ | break; | |
| 17467 | } | ||
| 17468 | |||
| 17469 | ✗ | tile += ((clk&6)>>1); | |
| 17470 | ✗ | } | |
| 17471 | else | ||
| 17472 | { | ||
| 17473 | ✗ | tile += (clk&4)?1:0; | |
| 17474 | } | ||
| 17475 | |||
| 17476 | ✗ | if(clk>=0) | |
| 17477 | ✗ | enemy::draw(dest); | |
| 17478 | ✗ | } | |
| 17479 | |||
| 17480 | |||
| 17481 | /**********************************/ | ||
| 17482 | /********** Misc Code ***********/ | ||
| 17483 | /**********************************/ | ||
| 17484 | |||
| 17485 | 484 | void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez) | |
| 17486 | { | ||
| 17487 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 484 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
484 | if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10)) |
| 17488 |
4/8✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 484 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 484 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 484 times.
✗ Branch 7 not taken.
|
484 | Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated)); |
| 17489 |
1/2✓ Branch 0 taken 484 times.
✗ Branch 1 not taken.
|
484 | if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez; |
| 17490 | 484 | } | |
| 17491 | |||
| 17492 | 1697 | int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap) | |
| 17493 | { | ||
| 17494 | // Kludge | ||
| 17495 |
4/8✓ Branch 0 taken 1697 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1697 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1697 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1697 times.
✗ Branch 7 not taken.
|
1697 | weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false); |
| 17496 | 1697 | int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap); | |
| 17497 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1697 times.
|
1697 | delete w; |
| 17498 | 1697 | return ret; | |
| 17499 | ✗ | } | |
| 17500 | |||
| 17501 | 125 | void enemy_scored(int32_t index) | |
| 17502 | { | ||
| 17503 | 125 | ((enemy*)guys.spr(index))->scored=true; | |
| 17504 | 125 | } | |
| 17505 | |||
| 17506 | 174 | void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr) | |
| 17507 | { | ||
| 17508 |
6/10✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 174 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 160 times.
✓ Branch 8 taken 174 times.
✗ Branch 9 not taken.
|
174 | guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy); |
| 17509 |
3/6✓ Branch 0 taken 70 times.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
174 | if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING)) |
| 17510 | { | ||
| 17511 | ✗ | g->o_tile = parentscr->guytile; | |
| 17512 | ✗ | if(g->o_tile != 0) | |
| 17513 | ✗ | g->flags &= ~guy_invisible; | |
| 17514 | ✗ | g->cs = parentscr->guycs; | |
| 17515 | ✗ | } | |
| 17516 | 174 | guys.add(g); | |
| 17517 | 174 | } | |
| 17518 | |||
| 17519 | 72 | void additem(int32_t x,int32_t y,int32_t id,int32_t pickup) | |
| 17520 | { | ||
| 17521 |
4/8✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 72 times.
✗ Branch 7 not taken.
|
72 | item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0); |
| 17522 | 72 | items.add(i); | |
| 17523 | 72 | } | |
| 17524 | |||
| 17525 | 20 | void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk) | |
| 17526 | { | ||
| 17527 |
5/10✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
|
20 | item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk); |
| 17528 | 20 | items.add(i); | |
| 17529 | 20 | } | |
| 17530 | |||
| 17531 | ✗ | void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup) | |
| 17532 | { | ||
| 17533 | ✗ | item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true); | |
| 17534 | ✗ | items.add(i); | |
| 17535 | ✗ | } | |
| 17536 | |||
| 17537 | 3 | void kill_em_all() | |
| 17538 | { | ||
| 17539 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
|
15 | for(int32_t i=0; i<guys.Count(); i++) |
| 17540 | { | ||
| 17541 | 12 | enemy *e = ((enemy*)guys.spr(i)); | |
| 17542 | |||
| 17543 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
12 | if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue; |
| 17544 | |||
| 17545 | 12 | e->kickbucket(); | |
| 17546 | 12 | } | |
| 17547 | 3 | } | |
| 17548 | |||
| 17549 | ✗ | bool can_kill_em_all() | |
| 17550 | { | ||
| 17551 | ✗ | for(int32_t i=0; i<guys.Count(); i++) | |
| 17552 | { | ||
| 17553 | ✗ | enemy *e = ((enemy*)guys.spr(i)); | |
| 17554 | |||
| 17555 | ✗ | if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue; | |
| 17556 | ✗ | if(e->superman) continue; | |
| 17557 | ✗ | return true; | |
| 17558 | } | ||
| 17559 | ✗ | return false; | |
| 17560 | ✗ | } | |
| 17561 | |||
| 17562 | //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero | ||
| 17563 | // For Hero's hit detection. Don't count them if they are stunned or are guys. | ||
| 17564 | ✗ | int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz) | |
| 17565 | { | ||
| 17566 | ✗ | for(int32_t i=0; i<guys.Count(); i++) | |
| 17567 | { | ||
| 17568 | ✗ | if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz)) | |
| 17569 | { | ||
| 17570 | ✗ | if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker) | |
| 17571 | ✗ | &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1)) | |
| 17572 | { | ||
| 17573 | ✗ | return i; | |
| 17574 | } | ||
| 17575 | ✗ | } | |
| 17576 | ✗ | } | |
| 17577 | |||
| 17578 | ✗ | return -1; | |
| 17579 | ✗ | } | |
| 17580 | |||
| 17581 | 761534 | int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz) | |
| 17582 | { | ||
| 17583 |
4/4✓ Branch 0 taken 366 times.
✓ Branch 1 taken 761168 times.
✓ Branch 2 taken 792128 times.
✓ Branch 3 taken 760958 times.
|
1553086 | for(int32_t i=zc_max(0, index); i<guys.Count(); i++) |
| 17584 | { | ||
| 17585 |
2/2✓ Branch 0 taken 576 times.
✓ Branch 1 taken 791552 times.
|
792128 | if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz)) |
| 17586 | { | ||
| 17587 | 576 | return i; | |
| 17588 | } | ||
| 17589 | 791552 | } | |
| 17590 | |||
| 17591 | 760958 | return -1; | |
| 17592 | 761534 | } | |
| 17593 | |||
| 17594 | // For Hero's hit detection. Count them if they are dying. | ||
| 17595 | 1462 | int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz) | |
| 17596 | { | ||
| 17597 | 1462 | enemy *e = (enemy*)guys.spr(index); | |
| 17598 |
3/4✓ Branch 0 taken 1462 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 793 times.
|
1462 | if(!e || e->hp > 0) |
| 17599 | 669 | return -1; | |
| 17600 | |||
| 17601 | 793 | bool d = e->dying; | |
| 17602 | 793 | int32_t hc = e->hclk; | |
| 17603 | 793 | e->dying = false; | |
| 17604 | 793 | e->hclk = 0; | |
| 17605 | 793 | bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz); | |
| 17606 | 793 | e->dying = d; | |
| 17607 | 793 | e->hclk = hc; | |
| 17608 | |||
| 17609 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 791 times.
|
793 | return hit ? index : -1; |
| 17610 | 1462 | } | |
| 17611 | |||
| 17612 | 783704 | bool hasMainGuy() | |
| 17613 | { | ||
| 17614 |
2/2✓ Branch 0 taken 403554 times.
✓ Branch 1 taken 537091 times.
|
940645 | for(int32_t i=0; i<guys.Count(); i++) |
| 17615 | { | ||
| 17616 |
2/2✓ Branch 0 taken 246613 times.
✓ Branch 1 taken 156941 times.
|
403554 | if(((enemy*)guys.spr(i))->mainguy) |
| 17617 | { | ||
| 17618 | 246613 | return true; | |
| 17619 | } | ||
| 17620 | 156941 | } | |
| 17621 | |||
| 17622 | 537091 | return false; | |
| 17623 | 783704 | } | |
| 17624 | |||
| 17625 | ✗ | void EatHero(int32_t index) | |
| 17626 | { | ||
| 17627 | ✗ | ((eStalfos*)guys.spr(index))->eathero(); | |
| 17628 | ✗ | } | |
| 17629 | |||
| 17630 | ✗ | void GrabHero(int32_t index) | |
| 17631 | { | ||
| 17632 | ✗ | ((eWallM*)guys.spr(index))->grabhero(); | |
| 17633 | ✗ | } | |
| 17634 | |||
| 17635 | ✗ | bool CarryHero() | |
| 17636 | { | ||
| 17637 | ✗ | for(int32_t i=0; i<guys.Count(); i++) | |
| 17638 | { | ||
| 17639 | ✗ | if(((guy*)(guys.spr(i)))->family==eeWALLM) | |
| 17640 | { | ||
| 17641 | ✗ | if(((eWallM*)guys.spr(i))->hashero) | |
| 17642 | { | ||
| 17643 | ✗ | Hero.x=guys.spr(i)->x; | |
| 17644 | ✗ | Hero.y=guys.spr(i)->y; | |
| 17645 | ✗ | return ((eWallM*)guys.spr(i))->misc > 0; | |
| 17646 | } | ||
| 17647 | ✗ | } | |
| 17648 | |||
| 17649 | // Like Likes currently can't carry Hero. | ||
| 17650 | /* | ||
| 17651 | if(((guy*)(guys.spr(i)))->family==eeLIKE) | ||
| 17652 | { | ||
| 17653 | if(((eLikeLike*)guys.spr(i))->hashero) | ||
| 17654 | { | ||
| 17655 | Hero.x=guys.spr(i)->x; | ||
| 17656 | Hero.y=guys.spr(i)->y; | ||
| 17657 | return (true); | ||
| 17658 | } | ||
| 17659 | }*/ | ||
| 17660 | ✗ | } | |
| 17661 | |||
| 17662 | ✗ | return false; | |
| 17663 | ✗ | } | |
| 17664 | |||
| 17665 | // Move item with guy | ||
| 17666 | ✗ | void movefairy(zfix &x,zfix &y,int32_t misc) | |
| 17667 | { | ||
| 17668 | ✗ | int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc); | |
| 17669 | |||
| 17670 | ✗ | if(i!=-1) | |
| 17671 | { | ||
| 17672 | ✗ | x = guys.spr(i)->x; | |
| 17673 | ✗ | y = guys.spr(i)->y; | |
| 17674 | ✗ | } | |
| 17675 | ✗ | } | |
| 17676 | |||
| 17677 | // Move guy with item (used by FFC scripts and hookshot-dragged fairies) | ||
| 17678 | ✗ | void movefairy2(zfix x,zfix y,int32_t misc) | |
| 17679 | { | ||
| 17680 | ✗ | int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc); | |
| 17681 | |||
| 17682 | ✗ | if(i!=-1) | |
| 17683 | { | ||
| 17684 | ✗ | guys.spr(i)->x = x; | |
| 17685 | ✗ | guys.spr(i)->y = y; | |
| 17686 | ✗ | } | |
| 17687 | ✗ | }// Move item with guy | |
| 17688 | |||
| 17689 | 1224 | void movefairynew(zfix &x,zfix &y, item const &itemfairy) | |
| 17690 | { | ||
| 17691 | 1224 | enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID); | |
| 17692 | |||
| 17693 |
1/2✓ Branch 0 taken 1224 times.
✗ Branch 1 not taken.
|
1224 | if(fairy) |
| 17694 | { | ||
| 17695 | 1224 | x = fairy->x; | |
| 17696 | 1224 | y = fairy->y; | |
| 17697 | 1224 | } | |
| 17698 | 1224 | } | |
| 17699 | |||
| 17700 | // Move guy with item (used by FFC scripts and hookshot-dragged fairies) | ||
| 17701 | ✗ | void movefairynew2(zfix x,zfix y, item const &itemfairy) | |
| 17702 | { | ||
| 17703 | ✗ | enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID); | |
| 17704 | |||
| 17705 | ✗ | if(fairy) | |
| 17706 | { | ||
| 17707 | ✗ | fairy->x = x; | |
| 17708 | ✗ | fairy->y = y; | |
| 17709 | ✗ | } | |
| 17710 | ✗ | } | |
| 17711 | |||
| 17712 | ✗ | void killfairy(int32_t misc) | |
| 17713 | { | ||
| 17714 | ✗ | int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc); | |
| 17715 | ✗ | guys.del(i); | |
| 17716 | ✗ | } | |
| 17717 | |||
| 17718 | ✗ | int32_t getGuyIndex(const int32_t eid) | |
| 17719 | { | ||
| 17720 | ✗ | for(word i = 0; i < guys.Count(); i++) | |
| 17721 | { | ||
| 17722 | ✗ | if(guys.spr(i)->getUID() == eid) | |
| 17723 | ✗ | return i; | |
| 17724 | ✗ | } | |
| 17725 | |||
| 17726 | ✗ | return -1; | |
| 17727 | ✗ | } | |
| 17728 | |||
| 17729 | ✗ | void killfairynew(item const &itemfairy) | |
| 17730 | { | ||
| 17731 | ✗ | enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID); | |
| 17732 | ✗ | if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID)); | |
| 17733 | ✗ | } | |
| 17734 | |||
| 17735 | //Should probably change this to return an 'enemy*', null on failure -Em | ||
| 17736 | 758 | int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk) | |
| 17737 | { | ||
| 17738 | 758 | return addenemy(x,y,0,id,clk); | |
| 17739 | } | ||
| 17740 | |||
| 17741 | 2 | int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID) | |
| 17742 | { | ||
| 17743 | 2 | return addchild(x,y,0,id,clk, parent_scriptUID); | |
| 17744 | } | ||
| 17745 | |||
| 17746 | 2 | int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID) | |
| 17747 | { | ||
| 17748 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(id <= 0) return 0; |
| 17749 | |||
| 17750 | 2 | int32_t ret = 0; | |
| 17751 | 2 | sprite *e=NULL; | |
| 17752 | 2 | al_trace("Adding child\n"); | |
| 17753 | |||
| 17754 |
1/31✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
2 | switch(guysbuf[id&0xFFF].family) |
| 17755 | { | ||
| 17756 | //Fixme: possible enemy memory leak. (minor) | ||
| 17757 | case eeWALK: | ||
| 17758 | ✗ | e = new eStalfos((zfix)x,(zfix)y,id,clk); | |
| 17759 | ✗ | break; | |
| 17760 | |||
| 17761 | case eeLEV: | ||
| 17762 | ✗ | e = new eLeever((zfix)x,(zfix)y,id,clk); | |
| 17763 | ✗ | break; | |
| 17764 | |||
| 17765 | case eeTEK: | ||
| 17766 | ✗ | e = new eTektite((zfix)x,(zfix)y,id,clk); | |
| 17767 | ✗ | break; | |
| 17768 | |||
| 17769 | case eePEAHAT: | ||
| 17770 | ✗ | e = new ePeahat((zfix)x,(zfix)y,id,clk); | |
| 17771 | ✗ | break; | |
| 17772 | |||
| 17773 | case eeZORA: | ||
| 17774 | ✗ | e = new eZora((zfix)x,(zfix)y,id,clk); | |
| 17775 | ✗ | break; | |
| 17776 | |||
| 17777 | case eeGHINI: | ||
| 17778 | ✗ | e = new eGhini((zfix)x,(zfix)y,id,clk); | |
| 17779 | ✗ | break; | |
| 17780 | |||
| 17781 | case eeKEESE: | ||
| 17782 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | e = new eKeese((zfix)x,(zfix)y,id,clk); |
| 17783 | 2 | break; | |
| 17784 | |||
| 17785 | case eeWIZZ: | ||
| 17786 | ✗ | e = new eWizzrobe((zfix)x,(zfix)y,id,clk); | |
| 17787 | ✗ | break; | |
| 17788 | |||
| 17789 | case eePROJECTILE: | ||
| 17790 | ✗ | e = new eProjectile((zfix)x,(zfix)y,id,clk); | |
| 17791 | ✗ | break; | |
| 17792 | |||
| 17793 | case eeWALLM: | ||
| 17794 | ✗ | e = new eWallM((zfix)x,(zfix)y,id,clk); | |
| 17795 | ✗ | break; | |
| 17796 | |||
| 17797 | case eeAQUA: | ||
| 17798 | ✗ | e = new eAquamentus((zfix)x,(zfix)y,id,clk); | |
| 17799 | ✗ | break; | |
| 17800 | |||
| 17801 | case eeMOLD: | ||
| 17802 | ✗ | e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1))); | |
| 17803 | ✗ | break; | |
| 17804 | |||
| 17805 | case eeMANHAN: | ||
| 17806 | ✗ | e = new eManhandla((zfix)x,(zfix)y,id,clk); | |
| 17807 | ✗ | break; | |
| 17808 | |||
| 17809 | case eeGLEEOK: | ||
| 17810 | ✗ | e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1))); | |
| 17811 | ✗ | break; | |
| 17812 | |||
| 17813 | case eeGHOMA: | ||
| 17814 | ✗ | e = new eGohma((zfix)x,(zfix)y,id,clk); | |
| 17815 | ✗ | break; | |
| 17816 | |||
| 17817 | case eeLANM: | ||
| 17818 | ✗ | e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1))); | |
| 17819 | ✗ | break; | |
| 17820 | |||
| 17821 | case eeGANON: | ||
| 17822 | ✗ | e = new eGanon((zfix)x,(zfix)y,id,clk); | |
| 17823 | ✗ | break; | |
| 17824 | |||
| 17825 | case eeFAIRY: | ||
| 17826 | ✗ | e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk); | |
| 17827 | ✗ | break; | |
| 17828 | |||
| 17829 | case eeFIRE: | ||
| 17830 | ✗ | e = new eFire((zfix)x,(zfix)y,id,clk); | |
| 17831 | ✗ | break; | |
| 17832 | |||
| 17833 | case eeOTHER: | ||
| 17834 | ✗ | e = new eOther((zfix)x,(zfix)y,id,clk); | |
| 17835 | ✗ | break; | |
| 17836 | |||
| 17837 | |||
| 17838 | case eeSCRIPT01: | ||
| 17839 | case eeSCRIPT02: | ||
| 17840 | case eeSCRIPT03: | ||
| 17841 | case eeSCRIPT04: | ||
| 17842 | case eeSCRIPT05: | ||
| 17843 | case eeSCRIPT06: | ||
| 17844 | case eeSCRIPT07: | ||
| 17845 | case eeSCRIPT08: | ||
| 17846 | case eeSCRIPT09: | ||
| 17847 | case eeSCRIPT10: | ||
| 17848 | case eeSCRIPT11: | ||
| 17849 | case eeSCRIPT12: | ||
| 17850 | case eeSCRIPT13: | ||
| 17851 | case eeSCRIPT14: | ||
| 17852 | case eeSCRIPT15: | ||
| 17853 | case eeSCRIPT16: | ||
| 17854 | case eeSCRIPT17: | ||
| 17855 | case eeSCRIPT18: | ||
| 17856 | case eeSCRIPT19: | ||
| 17857 | case eeSCRIPT20: | ||
| 17858 | { | ||
| 17859 | ✗ | if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) ) | |
| 17860 | { | ||
| 17861 | ✗ | e = new eScript((zfix)x,(zfix)y,id,clk); | |
| 17862 | ✗ | break; | |
| 17863 | } | ||
| 17864 | ✗ | else return 0; | |
| 17865 | } | ||
| 17866 | |||
| 17867 | case eeFFRIENDLY01: | ||
| 17868 | case eeFFRIENDLY02: | ||
| 17869 | case eeFFRIENDLY03: | ||
| 17870 | case eeFFRIENDLY04: | ||
| 17871 | case eeFFRIENDLY05: | ||
| 17872 | case eeFFRIENDLY06: | ||
| 17873 | case eeFFRIENDLY07: | ||
| 17874 | case eeFFRIENDLY08: | ||
| 17875 | case eeFFRIENDLY09: | ||
| 17876 | case eeFFRIENDLY10: | ||
| 17877 | { | ||
| 17878 | ✗ | if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) ) | |
| 17879 | { | ||
| 17880 | ✗ | e = new eFriendly((zfix)x,(zfix)y,id,clk); break; | |
| 17881 | } | ||
| 17882 | ✗ | else return 0; | |
| 17883 | |||
| 17884 | } | ||
| 17885 | |||
| 17886 | case eeSPINTILE: | ||
| 17887 | ✗ | e = new eSpinTile((zfix)x,(zfix)y,id,clk); | |
| 17888 | ✗ | break; | |
| 17889 | |||
| 17890 | // and these enemies use the misc10/misc2 value | ||
| 17891 | case eeROCK: | ||
| 17892 | { | ||
| 17893 | ✗ | switch(guysbuf[id&0xFFF].misc10) | |
| 17894 | { | ||
| 17895 | case 1: | ||
| 17896 | ✗ | e = new eBoulder((zfix)x,(zfix)y,id,clk); | |
| 17897 | ✗ | break; | |
| 17898 | |||
| 17899 | ✗ | case 0: | |
| 17900 | default: | ||
| 17901 | ✗ | e = new eRock((zfix)x,(zfix)y,id,clk); | |
| 17902 | ✗ | break; | |
| 17903 | } | ||
| 17904 | |||
| 17905 | ✗ | break; | |
| 17906 | } | ||
| 17907 | |||
| 17908 | case eeTRAP: | ||
| 17909 | { | ||
| 17910 | ✗ | switch(guysbuf[id&0xFFF].misc2) | |
| 17911 | { | ||
| 17912 | case 1: | ||
| 17913 | ✗ | e = new eTrap2((zfix)x,(zfix)y,id,clk); | |
| 17914 | ✗ | break; | |
| 17915 | |||
| 17916 | ✗ | case 0: | |
| 17917 | default: | ||
| 17918 | ✗ | e = new eTrap((zfix)x,(zfix)y,id,clk); | |
| 17919 | ✗ | break; | |
| 17920 | } | ||
| 17921 | |||
| 17922 | ✗ | break; | |
| 17923 | } | ||
| 17924 | |||
| 17925 | case eeDONGO: | ||
| 17926 | { | ||
| 17927 | ✗ | switch(guysbuf[id&0xFFF].misc10) | |
| 17928 | { | ||
| 17929 | case 1: | ||
| 17930 | ✗ | e = new eDodongo2((zfix)x,(zfix)y,id,clk); | |
| 17931 | ✗ | break; | |
| 17932 | |||
| 17933 | ✗ | case 0: | |
| 17934 | default: | ||
| 17935 | ✗ | e = new eDodongo((zfix)x,(zfix)y,id,clk); | |
| 17936 | ✗ | break; | |
| 17937 | } | ||
| 17938 | |||
| 17939 | ✗ | break; | |
| 17940 | } | ||
| 17941 | |||
| 17942 | case eeDIG: | ||
| 17943 | { | ||
| 17944 | ✗ | switch(guysbuf[id&0xFFF].misc10) | |
| 17945 | { | ||
| 17946 | case 1: | ||
| 17947 | ✗ | e = new eLilDig((zfix)x,(zfix)y,id,clk); | |
| 17948 | ✗ | break; | |
| 17949 | |||
| 17950 | ✗ | case 0: | |
| 17951 | default: | ||
| 17952 | ✗ | e = new eBigDig((zfix)x,(zfix)y,id,clk); | |
| 17953 | ✗ | break; | |
| 17954 | } | ||
| 17955 | |||
| 17956 | ✗ | break; | |
| 17957 | } | ||
| 17958 | |||
| 17959 | case eePATRA: | ||
| 17960 | { | ||
| 17961 | ✗ | switch(guysbuf[id&0xFFF].misc10) | |
| 17962 | { | ||
| 17963 | case 1: | ||
| 17964 | ✗ | if (get_qr(qr_HARDCODED_BS_PATRA)) | |
| 17965 | { | ||
| 17966 | ✗ | e = new ePatraBS((zfix)x,(zfix)y,id,clk); | |
| 17967 | ✗ | break; | |
| 17968 | } | ||
| 17969 | [[fallthrough]]; | ||
| 17970 | ✗ | case 0: | |
| 17971 | default: | ||
| 17972 | ✗ | e = new ePatra((zfix)x,(zfix)y,id,clk); | |
| 17973 | ✗ | break; | |
| 17974 | } | ||
| 17975 | |||
| 17976 | ✗ | break; | |
| 17977 | } | ||
| 17978 | |||
| 17979 | case eeGUY: | ||
| 17980 | { | ||
| 17981 | ✗ | switch(guysbuf[id&0xFFF].misc10) | |
| 17982 | { | ||
| 17983 | case 1: | ||
| 17984 | ✗ | e = new eTrigger((zfix)x,(zfix)y,id,clk); | |
| 17985 | ✗ | break; | |
| 17986 | |||
| 17987 | ✗ | case 0: | |
| 17988 | default: | ||
| 17989 | ✗ | e = new eNPC((zfix)x,(zfix)y,id,clk); | |
| 17990 | ✗ | break; | |
| 17991 | } | ||
| 17992 | |||
| 17993 | ✗ | break; | |
| 17994 | } | ||
| 17995 | |||
| 17996 | case eeNONE: | ||
| 17997 | ✗ | if(guysbuf[id&0xFFF].misc10 ==1) | |
| 17998 | { | ||
| 17999 | ✗ | e = new eTrigger((zfix)x,(zfix)y,id,clk); | |
| 18000 | ✗ | break; | |
| 18001 | break; | ||
| 18002 | } | ||
| 18003 | [[fallthrough]]; | ||
| 18004 | default: | ||
| 18005 | |||
| 18006 | ✗ | return 0; | |
| 18007 | } | ||
| 18008 | |||
| 18009 | 2 | ret++; // Made one enemy. | |
| 18010 | |||
| 18011 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2 | if(z && canfall(id)) |
| 18012 | { | ||
| 18013 | ✗ | e->z = (zfix)z; | |
| 18014 | ✗ | } | |
| 18015 | |||
| 18016 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | ((enemy*)e)->ceiling = (z && canfall(id)); |
| 18017 | 2 | ((enemy*)e)->parent_script_UID = parent_scriptUID; | |
| 18018 | //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID); | ||
| 18019 | //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID); | ||
| 18020 | //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID); | ||
| 18021 | //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID); | ||
| 18022 | |||
| 18023 | |||
| 18024 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(!guys.add(e)) |
| 18025 | { | ||
| 18026 | ✗ | return 0; | |
| 18027 | } | ||
| 18028 | |||
| 18029 | // add segments of segmented enemies | ||
| 18030 | 2 | int32_t c=0; | |
| 18031 | |||
| 18032 |
1/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
2 | switch(guysbuf[id&0xFFF].family) |
| 18033 | { | ||
| 18034 | case eeMOLD: | ||
| 18035 | { | ||
| 18036 | ✗ | byte is=((enemy*)guys.spr(guys.Count()-1))->item_set; | |
| 18037 | ✗ | id &= 0xFFF; | |
| 18038 | |||
| 18039 | ✗ | for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++) | |
| 18040 | { | ||
| 18041 | //christ this is messy -DD | ||
| 18042 | ✗ | int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100)))); | |
| 18043 | |||
| 18044 | ✗ | if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk))) | |
| 18045 | { | ||
| 18046 | ✗ | al_trace("Moldorm segment %d could not be created!\n",i+1); | |
| 18047 | |||
| 18048 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18049 | ✗ | guys.del(guys.Count()-1); | |
| 18050 | |||
| 18051 | ✗ | return 0; | |
| 18052 | } | ||
| 18053 | |||
| 18054 | ✗ | if(i>0) | |
| 18055 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->item_set=is; | |
| 18056 | |||
| 18057 | ✗ | ret++; | |
| 18058 | ✗ | } | |
| 18059 | |||
| 18060 | ✗ | break; | |
| 18061 | } | ||
| 18062 | |||
| 18063 | case eeLANM: | ||
| 18064 | { | ||
| 18065 | ✗ | id &= 0xFFF; | |
| 18066 | ✗ | int32_t shft = guysbuf[id].misc2; | |
| 18067 | ✗ | byte is=((enemy*)guys.spr(guys.Count()-1))->item_set; | |
| 18068 | |||
| 18069 | ✗ | if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0))) | |
| 18070 | { | ||
| 18071 | ✗ | al_trace("Lanmola segment 1 could not be created!\n"); | |
| 18072 | ✗ | guys.del(guys.Count()-1); | |
| 18073 | ✗ | return 0; | |
| 18074 | } | ||
| 18075 | |||
| 18076 | ✗ | ret++; | |
| 18077 | |||
| 18078 | ✗ | for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++) | |
| 18079 | { | ||
| 18080 | ✗ | if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft)))) | |
| 18081 | { | ||
| 18082 | ✗ | al_trace("Lanmola segment %d could not be created!\n",i+1); | |
| 18083 | |||
| 18084 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18085 | ✗ | guys.del(guys.Count()-1); | |
| 18086 | |||
| 18087 | ✗ | return 0; | |
| 18088 | } | ||
| 18089 | |||
| 18090 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->item_set=is; | |
| 18091 | ✗ | ret++; | |
| 18092 | ✗ | } | |
| 18093 | } | ||
| 18094 | ✗ | break; | |
| 18095 | |||
| 18096 | case eeMANHAN: | ||
| 18097 | ✗ | id &= 0xFFF; | |
| 18098 | |||
| 18099 | ✗ | for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++) | |
| 18100 | { | ||
| 18101 | ✗ | if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i))) | |
| 18102 | { | ||
| 18103 | ✗ | al_trace("Manhandla head %d could not be created!\n",i+1); | |
| 18104 | |||
| 18105 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18106 | { | ||
| 18107 | ✗ | guys.del(guys.Count()-1); | |
| 18108 | ✗ | } | |
| 18109 | |||
| 18110 | ✗ | return 0; | |
| 18111 | } | ||
| 18112 | |||
| 18113 | ✗ | ret++; | |
| 18114 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1; | |
| 18115 | ✗ | } | |
| 18116 | |||
| 18117 | ✗ | break; | |
| 18118 | |||
| 18119 | case eeGLEEOK: | ||
| 18120 | { | ||
| 18121 | ✗ | id &= 0xFFF; | |
| 18122 | |||
| 18123 | ✗ | for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++) | |
| 18124 | { | ||
| 18125 | ✗ | if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e))) | |
| 18126 | { | ||
| 18127 | ✗ | al_trace("Gleeok head %d could not be created!\n",i+1); | |
| 18128 | |||
| 18129 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18130 | { | ||
| 18131 | ✗ | guys.del(guys.Count()-1); | |
| 18132 | ✗ | } | |
| 18133 | |||
| 18134 | ✗ | return false; | |
| 18135 | } | ||
| 18136 | |||
| 18137 | ✗ | c-=guysbuf[id].misc4; | |
| 18138 | ✗ | ret++; | |
| 18139 | ✗ | } | |
| 18140 | } | ||
| 18141 | ✗ | break; | |
| 18142 | |||
| 18143 | |||
| 18144 | case eePATRA: | ||
| 18145 | { | ||
| 18146 | ✗ | id &= 0xFFF; | |
| 18147 | ✗ | int32_t outeyes = 0; | |
| 18148 | |||
| 18149 | ✗ | for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++) | |
| 18150 | { | ||
| 18151 | ✗ | if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))) | |
| 18152 | { | ||
| 18153 | ✗ | al_trace("Patra outer eye %d could not be created!\n",i+1); | |
| 18154 | |||
| 18155 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18156 | ✗ | guys.del(guys.Count()-1); | |
| 18157 | |||
| 18158 | ✗ | return 0; | |
| 18159 | } | ||
| 18160 | else | ||
| 18161 | ✗ | outeyes++; | |
| 18162 | |||
| 18163 | ✗ | ret++; | |
| 18164 | ✗ | } | |
| 18165 | |||
| 18166 | ✗ | for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++) | |
| 18167 | { | ||
| 18168 | ✗ | if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))) | |
| 18169 | { | ||
| 18170 | ✗ | al_trace("Patra inner eye %d could not be created!\n",i+1); | |
| 18171 | |||
| 18172 | ✗ | for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++) | |
| 18173 | ✗ | guys.del(guys.Count()-1); | |
| 18174 | |||
| 18175 | ✗ | return 0; | |
| 18176 | } | ||
| 18177 | |||
| 18178 | ✗ | ret++; | |
| 18179 | ✗ | } | |
| 18180 | |||
| 18181 | ✗ | break; | |
| 18182 | } | ||
| 18183 | } | ||
| 18184 | |||
| 18185 | 2 | return ret; | |
| 18186 | 2 | } | |
| 18187 | |||
| 18188 | // Returns number of enemies/segments created | ||
| 18189 | 2922 | int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk) | |
| 18190 | { | ||
| 18191 | //zprint2("addenemy id is: %d\n", (id&0xFFF)); | ||
| 18192 | 2922 | int32_t realid = id&0xFFF; | |
| 18193 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2922 times.
|
2922 | if( realid > MAXGUYS ) |
| 18194 | { | ||
| 18195 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()"); | ||
| 18196 | ✗ | return 0; | |
| 18197 | } | ||
| 18198 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2922 times.
|
2922 | if(id <= 0) return 0; |
| 18199 | |||
| 18200 | 2922 | int32_t ret = 0; | |
| 18201 | 2922 | sprite *e=NULL; | |
| 18202 | |||
| 18203 |
26/31✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1769 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 77 times.
✓ Branch 7 taken 94 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 385 times.
✓ Branch 10 taken 128 times.
✓ Branch 11 taken 77 times.
✓ Branch 12 taken 37 times.
✓ Branch 13 taken 7 times.
✓ Branch 14 taken 11 times.
✓ Branch 15 taken 5 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 2 times.
✓ Branch 18 taken 8 times.
✓ Branch 19 taken 2 times.
✓ Branch 20 taken 20 times.
✓ Branch 21 taken 8 times.
✓ Branch 22 taken 10 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 18 times.
✓ Branch 25 taken 52 times.
✓ Branch 26 taken 7 times.
✓ Branch 27 taken 7 times.
✓ Branch 28 taken 4 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 2 times.
|
2922 | switch(guysbuf[id&0xFFF].family) |
| 18204 | { | ||
| 18205 | //Fixme: possible enemy memory leak. (minor) | ||
| 18206 | case eeWALK: | ||
| 18207 |
3/6✓ Branch 0 taken 1769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1769 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1769 times.
✗ Branch 5 not taken.
|
1769 | e = new eStalfos((zfix)x,(zfix)y,id,clk); |
| 18208 | 1769 | break; | |
| 18209 | |||
| 18210 | case eeLEV: | ||
| 18211 |
3/6✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
|
83 | e = new eLeever((zfix)x,(zfix)y,id,clk); |
| 18212 | 83 | break; | |
| 18213 | |||
| 18214 | case eeTEK: | ||
| 18215 |
3/6✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
|
105 | e = new eTektite((zfix)x,(zfix)y,id,clk); |
| 18216 | 105 | break; | |
| 18217 | |||
| 18218 | case eePEAHAT: | ||
| 18219 |
3/6✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
|
77 | e = new ePeahat((zfix)x,(zfix)y,id,clk); |
| 18220 | 77 | break; | |
| 18221 | |||
| 18222 | case eeZORA: | ||
| 18223 |
3/6✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
|
94 | e = new eZora((zfix)x,(zfix)y,id,clk); |
| 18224 | 94 | break; | |
| 18225 | |||
| 18226 | case eeGHINI: | ||
| 18227 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | e = new eGhini((zfix)x,(zfix)y,id,clk); |
| 18228 | 1 | break; | |
| 18229 | |||
| 18230 | case eeKEESE: | ||
| 18231 |
3/6✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 385 times.
✗ Branch 5 not taken.
|
385 | e = new eKeese((zfix)x,(zfix)y,id,clk); |
| 18232 | 385 | break; | |
| 18233 | |||
| 18234 | case eeWIZZ: | ||
| 18235 |
3/6✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
|
128 | e = new eWizzrobe((zfix)x,(zfix)y,id,clk); |
| 18236 | 128 | break; | |
| 18237 | |||
| 18238 | case eePROJECTILE: | ||
| 18239 |
3/6✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✗ Branch 5 not taken.
|
77 | e = new eProjectile((zfix)x,(zfix)y,id,clk); |
| 18240 | 77 | break; | |
| 18241 | |||
| 18242 | case eeWALLM: | ||
| 18243 |
3/6✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
|
37 | e = new eWallM((zfix)x,(zfix)y,id,clk); |
| 18244 | 37 | break; | |
| 18245 | |||
| 18246 | case eeAQUA: | ||
| 18247 |
3/6✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | e = new eAquamentus((zfix)x,(zfix)y,id,clk); |
| 18248 | 7 | break; | |
| 18249 | |||
| 18250 | case eeMOLD: | ||
| 18251 |
6/12✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 11 times.
✓ Branch 10 taken 11 times.
✗ Branch 11 not taken.
|
11 | e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1))); |
| 18252 | 11 | break; | |
| 18253 | |||
| 18254 | case eeMANHAN: | ||
| 18255 |
3/6✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | e = new eManhandla((zfix)x,(zfix)y,id,clk); |
| 18256 | 5 | break; | |
| 18257 | |||
| 18258 | case eeGLEEOK: | ||
| 18259 |
6/12✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
|
3 | e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1))); |
| 18260 | 3 | break; | |
| 18261 | |||
| 18262 | case eeGHOMA: | ||
| 18263 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | e = new eGohma((zfix)x,(zfix)y,id,clk); |
| 18264 | 2 | break; | |
| 18265 | |||
| 18266 | case eeLANM: | ||
| 18267 |
6/12✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
|
8 | e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1))); |
| 18268 | 8 | break; | |
| 18269 | |||
| 18270 | case eeGANON: | ||
| 18271 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | e = new eGanon((zfix)x,(zfix)y,id,clk); |
| 18272 | 2 | break; | |
| 18273 | |||
| 18274 | case eeFAIRY: | ||
| 18275 |
3/6✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
20 | e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk); |
| 18276 | 20 | break; | |
| 18277 | |||
| 18278 | case eeFIRE: | ||
| 18279 |
3/6✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
|
8 | e = new eFire((zfix)x,(zfix)y,id,clk); |
| 18280 | 8 | break; | |
| 18281 | |||
| 18282 | case eeOTHER: | ||
| 18283 |
3/6✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
|
10 | e = new eOther((zfix)x,(zfix)y,id,clk); |
| 18284 | 10 | break; | |
| 18285 | |||
| 18286 | |||
| 18287 | case eeSCRIPT01: | ||
| 18288 | case eeSCRIPT02: | ||
| 18289 | case eeSCRIPT03: | ||
| 18290 | case eeSCRIPT04: | ||
| 18291 | case eeSCRIPT05: | ||
| 18292 | case eeSCRIPT06: | ||
| 18293 | case eeSCRIPT07: | ||
| 18294 | case eeSCRIPT08: | ||
| 18295 | case eeSCRIPT09: | ||
| 18296 | case eeSCRIPT10: | ||
| 18297 | case eeSCRIPT11: | ||
| 18298 | case eeSCRIPT12: | ||
| 18299 | case eeSCRIPT13: | ||
| 18300 | case eeSCRIPT14: | ||
| 18301 | case eeSCRIPT15: | ||
| 18302 | case eeSCRIPT16: | ||
| 18303 | case eeSCRIPT17: | ||
| 18304 | case eeSCRIPT18: | ||
| 18305 | case eeSCRIPT19: | ||
| 18306 | case eeSCRIPT20: | ||
| 18307 | { | ||
| 18308 | ✗ | if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) ) | |
| 18309 | { | ||
| 18310 | ✗ | e = new eScript((zfix)x,(zfix)y,id,clk); | |
| 18311 | ✗ | break; | |
| 18312 | } | ||
| 18313 | ✗ | else return 0; | |
| 18314 | } | ||
| 18315 | |||
| 18316 | case eeFFRIENDLY01: | ||
| 18317 | case eeFFRIENDLY02: | ||
| 18318 | case eeFFRIENDLY03: | ||
| 18319 | case eeFFRIENDLY04: | ||
| 18320 | case eeFFRIENDLY05: | ||
| 18321 | case eeFFRIENDLY06: | ||
| 18322 | case eeFFRIENDLY07: | ||
| 18323 | case eeFFRIENDLY08: | ||
| 18324 | case eeFFRIENDLY09: | ||
| 18325 | case eeFFRIENDLY10: | ||
| 18326 | { | ||
| 18327 | ✗ | if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) ) | |
| 18328 | { | ||
| 18329 | ✗ | e = new eFriendly((zfix)x,(zfix)y,id,clk); break; | |
| 18330 | } | ||
| 18331 | ✗ | else return 0; | |
| 18332 | |||
| 18333 | } | ||
| 18334 | |||
| 18335 | case eeSPINTILE: | ||
| 18336 | ✗ | e = new eSpinTile((zfix)x,(zfix)y,id,clk); | |
| 18337 | ✗ | break; | |
| 18338 | |||
| 18339 | // and these enemies use the misc10/misc2 value | ||
| 18340 | case eeROCK: | ||
| 18341 | { | ||
| 18342 |
1/3✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
|
18 | switch(guysbuf[id&0xFFF].misc10) |
| 18343 | { | ||
| 18344 | case 1: | ||
| 18345 | ✗ | e = new eBoulder((zfix)x,(zfix)y,id,clk); | |
| 18346 | ✗ | break; | |
| 18347 | |||
| 18348 | 18 | case 0: | |
| 18349 | default: | ||
| 18350 |
3/6✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
|
18 | e = new eRock((zfix)x,(zfix)y,id,clk); |
| 18351 | 18 | break; | |
| 18352 | } | ||
| 18353 | |||
| 18354 | 18 | break; | |
| 18355 | } | ||
| 18356 | |||
| 18357 | case eeTRAP: | ||
| 18358 | { | ||
| 18359 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 48 times.
|
52 | switch(guysbuf[id&0xFFF].misc2) |
| 18360 | { | ||
| 18361 | case 1: | ||
| 18362 |
3/6✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | e = new eTrap2((zfix)x,(zfix)y,id,clk); |
| 18363 | 4 | break; | |
| 18364 | |||
| 18365 | 48 | case 0: | |
| 18366 | default: | ||
| 18367 |
3/6✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
|
48 | e = new eTrap((zfix)x,(zfix)y,id,clk); |
| 18368 | 48 | break; | |
| 18369 | } | ||
| 18370 | |||
| 18371 | 52 | break; | |
| 18372 | } | ||
| 18373 | |||
| 18374 | case eeDONGO: | ||
| 18375 | { | ||
| 18376 |
1/3✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
|
7 | switch(guysbuf[id&0xFFF].misc10) |
| 18377 | { | ||
| 18378 | case 1: | ||
| 18379 | ✗ | e = new eDodongo2((zfix)x,(zfix)y,id,clk); | |
| 18380 | ✗ | break; | |
| 18381 | |||
| 18382 | 7 | case 0: | |
| 18383 | default: | ||
| 18384 |
3/6✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
7 | e = new eDodongo((zfix)x,(zfix)y,id,clk); |
| 18385 | 7 | break; | |
| 18386 | } | ||
| 18387 | |||
| 18388 | 7 | break; | |
| 18389 | } | ||
| 18390 | |||
| 18391 | case eeDIG: | ||
| 18392 | { | ||
| 18393 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 3 times.
|
7 | switch(guysbuf[id&0xFFF].misc10) |
| 18394 | { | ||
| 18395 | case 1: | ||
| 18396 |
3/6✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | e = new eLilDig((zfix)x,(zfix)y,id,clk); |
| 18397 | 4 | break; | |
| 18398 | |||
| 18399 | 3 | case 0: | |
| 18400 | default: | ||
| 18401 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
|
3 | e = new eBigDig((zfix)x,(zfix)y,id,clk); |
| 18402 | 3 | break; | |
| 18403 | } | ||
| 18404 | |||
| 18405 | 7 | break; | |
| 18406 | } | ||
| 18407 | |||
| 18408 | case eePATRA: | ||
| 18409 | { | ||
| 18410 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | switch(guysbuf[id&0xFFF].misc10) |
| 18411 | { | ||
| 18412 | case 1: | ||
| 18413 | ✗ | if (get_qr(qr_HARDCODED_BS_PATRA)) | |
| 18414 | { | ||
| 18415 | ✗ | e = new ePatraBS((zfix)x,(zfix)y,id,clk); | |
| 18416 | ✗ | break; | |
| 18417 | } | ||
| 18418 | [[fallthrough]]; | ||
| 18419 | 4 | case 0: | |
| 18420 | default: | ||
| 18421 |
3/6✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
|
4 | e = new ePatra((zfix)x,(zfix)y,id,clk); |
| 18422 | 4 | break; | |
| 18423 | } | ||
| 18424 | |||
| 18425 | 4 | break; | |
| 18426 | } | ||
| 18427 | |||
| 18428 | case eeGUY: | ||
| 18429 | { | ||
| 18430 | ✗ | switch(guysbuf[id&0xFFF].misc10) | |
| 18431 | { | ||
| 18432 | case 1: | ||
| 18433 | ✗ | e = new eTrigger((zfix)x,(zfix)y,id,clk); | |
| 18434 | ✗ | break; | |
| 18435 | |||
| 18436 | ✗ | case 0: | |
| 18437 | default: | ||
| 18438 | ✗ | e = new eNPC((zfix)x,(zfix)y,id,clk); | |
| 18439 | ✗ | break; | |
| 18440 | } | ||
| 18441 | |||
| 18442 | ✗ | break; | |
| 18443 | } | ||
| 18444 | |||
| 18445 | case eeNONE: | ||
| 18446 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if(guysbuf[id&0xFFF].misc10 ==1) |
| 18447 | { | ||
| 18448 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | e = new eTrigger((zfix)x,(zfix)y,id,clk); |
| 18449 | 2 | break; | |
| 18450 | break; | ||
| 18451 | } | ||
| 18452 | [[fallthrough]]; | ||
| 18453 | default: | ||
| 18454 | |||
| 18455 | ✗ | return 0; | |
| 18456 | } | ||
| 18457 | |||
| 18458 | 2922 | ret++; // Made one enemy. | |
| 18459 | |||
| 18460 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2922 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2922 | if(z && canfall(id)) |
| 18461 | { | ||
| 18462 | ✗ | e->z = (zfix)z; | |
| 18463 | ✗ | } | |
| 18464 | |||
| 18465 |
1/2✓ Branch 0 taken 2922 times.
✗ Branch 1 not taken.
|
2922 | ((enemy*)e)->ceiling = (z && canfall(id)); |
| 18466 | |||
| 18467 |
1/2✓ Branch 0 taken 2922 times.
✗ Branch 1 not taken.
|
2922 | if(!guys.add(e)) |
| 18468 | { | ||
| 18469 | ✗ | return 0; | |
| 18470 | } | ||
| 18471 | |||
| 18472 | // add segments of segmented enemies | ||
| 18473 | 2922 | int32_t c=0; | |
| 18474 | |||
| 18475 |
6/6✓ Branch 0 taken 2891 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 4 times.
|
2922 | switch(guysbuf[id&0xFFF].family) |
| 18476 | { | ||
| 18477 | case eeMOLD: | ||
| 18478 | { | ||
| 18479 | 11 | byte is=((enemy*)guys.spr(guys.Count()-1))->item_set; | |
| 18480 | 11 | id &= 0xFFF; | |
| 18481 | |||
| 18482 |
5/8✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 66 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 11 times.
|
66 | for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++) |
| 18483 | { | ||
| 18484 | //christ this is messy -DD | ||
| 18485 | 55 | int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100)))); | |
| 18486 | |||
| 18487 |
4/8✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 55 times.
✗ Branch 7 not taken.
|
55 | if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk))) |
| 18488 | { | ||
| 18489 | ✗ | al_trace("Moldorm segment %d could not be created!\n",i+1); | |
| 18490 | |||
| 18491 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18492 | ✗ | guys.del(guys.Count()-1); | |
| 18493 | |||
| 18494 | ✗ | return 0; | |
| 18495 | } | ||
| 18496 | |||
| 18497 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 44 times.
|
55 | if(i>0) |
| 18498 | 44 | ((enemy*)guys.spr(guys.Count()-1))->item_set=is; | |
| 18499 | |||
| 18500 | 55 | ret++; | |
| 18501 | 55 | } | |
| 18502 | |||
| 18503 | 11 | break; | |
| 18504 | } | ||
| 18505 | |||
| 18506 | case eeLANM: | ||
| 18507 | { | ||
| 18508 | 8 | id &= 0xFFF; | |
| 18509 | 8 | int32_t shft = guysbuf[id].misc2; | |
| 18510 | 8 | byte is=((enemy*)guys.spr(guys.Count()-1))->item_set; | |
| 18511 | |||
| 18512 |
4/8✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
|
8 | if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0))) |
| 18513 | { | ||
| 18514 | ✗ | al_trace("Lanmola segment 1 could not be created!\n"); | |
| 18515 | ✗ | guys.del(guys.Count()-1); | |
| 18516 | ✗ | return 0; | |
| 18517 | } | ||
| 18518 | |||
| 18519 | 8 | ret++; | |
| 18520 | |||
| 18521 |
5/8✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 44 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 8 times.
|
44 | for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++) |
| 18522 | { | ||
| 18523 |
4/8✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36 times.
✗ Branch 7 not taken.
|
36 | if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft)))) |
| 18524 | { | ||
| 18525 | ✗ | al_trace("Lanmola segment %d could not be created!\n",i+1); | |
| 18526 | |||
| 18527 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18528 | ✗ | guys.del(guys.Count()-1); | |
| 18529 | |||
| 18530 | ✗ | return 0; | |
| 18531 | } | ||
| 18532 | |||
| 18533 | 36 | ((enemy*)guys.spr(guys.Count()-1))->item_set=is; | |
| 18534 | 36 | ret++; | |
| 18535 | 36 | } | |
| 18536 | } | ||
| 18537 | 8 | break; | |
| 18538 | |||
| 18539 | case eeMANHAN: | ||
| 18540 | 5 | id &= 0xFFF; | |
| 18541 | |||
| 18542 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5 times.
|
25 | for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++) |
| 18543 | { | ||
| 18544 |
4/8✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
|
20 | if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i))) |
| 18545 | { | ||
| 18546 | ✗ | al_trace("Manhandla head %d could not be created!\n",i+1); | |
| 18547 | |||
| 18548 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18549 | { | ||
| 18550 | ✗ | guys.del(guys.Count()-1); | |
| 18551 | ✗ | } | |
| 18552 | |||
| 18553 | ✗ | return 0; | |
| 18554 | } | ||
| 18555 | |||
| 18556 | 20 | ret++; | |
| 18557 | 20 | ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1; | |
| 18558 | 20 | } | |
| 18559 | |||
| 18560 | 5 | break; | |
| 18561 | |||
| 18562 | case eeGLEEOK: | ||
| 18563 | { | ||
| 18564 | 3 | id &= 0xFFF; | |
| 18565 | 3 | eGleeok* parent = (eGleeok*)e; | |
| 18566 | |||
| 18567 |
5/8✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 3 times.
|
12 | for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++) |
| 18568 | { | ||
| 18569 |
3/6✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
|
9 | esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e); |
| 18570 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | if(!guys.add(head)) |
| 18571 | { | ||
| 18572 | ✗ | al_trace("Gleeok head %d could not be created!\n",i+1); | |
| 18573 | |||
| 18574 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18575 | { | ||
| 18576 | ✗ | guys.del(guys.Count()-1); | |
| 18577 | ✗ | } | |
| 18578 | |||
| 18579 | ✗ | return false; | |
| 18580 | } | ||
| 18581 | |||
| 18582 | 9 | head->necktile=parent->necktile; | |
| 18583 | 9 | head->dummy_int[1]=parent->necktile; | |
| 18584 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(get_qr(qr_NEWENEMYTILES)) |
| 18585 | { | ||
| 18586 | ✗ | head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile | |
| 18587 | ✗ | head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile | |
| 18588 | ✗ | } | |
| 18589 | else | ||
| 18590 | { | ||
| 18591 | 9 | head->dummy_int[2]=parent->necktile+1; //connected head tile | |
| 18592 | 9 | head->dummy_int[3]=parent->necktile+2; //flying head tile | |
| 18593 | } | ||
| 18594 | 9 | head->tile = head->dummy_int[2]; | |
| 18595 | |||
| 18596 | 9 | c-=guysbuf[id].misc4; | |
| 18597 | 9 | ret++; | |
| 18598 | 9 | } | |
| 18599 | } | ||
| 18600 | 3 | break; | |
| 18601 | |||
| 18602 | |||
| 18603 | case eePATRA: | ||
| 18604 | { | ||
| 18605 | 4 | id &= 0xFFF; | |
| 18606 | 4 | int32_t outeyes = 0; | |
| 18607 | |||
| 18608 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 4 times.
|
36 | for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++) |
| 18609 | { | ||
| 18610 |
5/22✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 32 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 32 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 32 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
32 | if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))) |
| 18611 | { | ||
| 18612 | ✗ | al_trace("Patra outer eye %d could not be created!\n",i+1); | |
| 18613 | |||
| 18614 | ✗ | for(int32_t j=0; j<i+1; j++) | |
| 18615 | ✗ | guys.del(guys.Count()-1); | |
| 18616 | |||
| 18617 | ✗ | return 0; | |
| 18618 | } | ||
| 18619 | else | ||
| 18620 | 32 | outeyes++; | |
| 18621 | |||
| 18622 | 32 | ret++; | |
| 18623 | 32 | } | |
| 18624 | |||
| 18625 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
|
4 | for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++) |
| 18626 | { | ||
| 18627 | ✗ | if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))) | |
| 18628 | { | ||
| 18629 | ✗ | al_trace("Patra inner eye %d could not be created!\n",i+1); | |
| 18630 | |||
| 18631 | ✗ | for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++) | |
| 18632 | ✗ | guys.del(guys.Count()-1); | |
| 18633 | |||
| 18634 | ✗ | return 0; | |
| 18635 | } | ||
| 18636 | |||
| 18637 | ✗ | ret++; | |
| 18638 | ✗ | } | |
| 18639 | |||
| 18640 | 4 | break; | |
| 18641 | } | ||
| 18642 | } | ||
| 18643 | |||
| 18644 | 2922 | return ret; | |
| 18645 | 2922 | } | |
| 18646 | |||
| 18647 | 6041 | bool isjumper(int32_t id) | |
| 18648 | { | ||
| 18649 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6041 times.
|
6041 | if( ((unsigned)(id&0xFFF)) > MAXGUYS ) |
| 18650 | { | ||
| 18651 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()"); | ||
| 18652 | ✗ | return false; | |
| 18653 | } | ||
| 18654 |
2/3✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✓ Branch 2 taken 4436 times.
|
6041 | switch(guysbuf[id&0xFFF].family) |
| 18655 | { | ||
| 18656 | case eeROCK: | ||
| 18657 | case eeTEK: | ||
| 18658 | ✗ | return true; | |
| 18659 | |||
| 18660 | case eeWALK: | ||
| 18661 |
2/4✓ Branch 0 taken 4436 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4436 times.
|
4436 | if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true; |
| 18662 | 4436 | } | |
| 18663 | |||
| 18664 | 6041 | return false; | |
| 18665 | 6041 | } | |
| 18666 | |||
| 18667 | |||
| 18668 | 3246 | bool isfixedtogrid(int32_t id) | |
| 18669 | { | ||
| 18670 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3246 times.
|
3246 | if( ((unsigned)(id&0xFFF)) > MAXGUYS ) |
| 18671 | { | ||
| 18672 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()"); | ||
| 18673 | ✗ | return false; | |
| 18674 | } | ||
| 18675 |
1/2✓ Branch 0 taken 3246 times.
✗ Branch 1 not taken.
|
3246 | switch(guysbuf[id&0xFFF].family) |
| 18676 | { | ||
| 18677 | case eeWALK: | ||
| 18678 | case eeLEV: | ||
| 18679 | case eeZORA: | ||
| 18680 | case eeDONGO: | ||
| 18681 | case eeGANON: | ||
| 18682 | case eeROCK: | ||
| 18683 | case eeGLEEOK: | ||
| 18684 | case eeAQUA: | ||
| 18685 | case eeLANM: | ||
| 18686 | ✗ | return true; | |
| 18687 | } | ||
| 18688 | |||
| 18689 | 3246 | return false; | |
| 18690 | 3246 | } | |
| 18691 | |||
| 18692 | // Can't fall, can have Z value. | ||
| 18693 | 1293749 | bool isflier(int32_t id) | |
| 18694 | { | ||
| 18695 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1293749 times.
|
1293749 | if( ((unsigned)(id&0xFFF)) > MAXGUYS ) |
| 18696 | { | ||
| 18697 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()"); | ||
| 18698 | ✗ | return false; | |
| 18699 | } | ||
| 18700 |
2/2✓ Branch 0 taken 1155492 times.
✓ Branch 1 taken 138257 times.
|
1293749 | switch(guysbuf[id&0xFFF].family) //id&0x0FFF) |
| 18701 | { | ||
| 18702 | case eePEAHAT: | ||
| 18703 | case eeKEESE: | ||
| 18704 | case eePATRA: | ||
| 18705 | case eeFAIRY: | ||
| 18706 | case eeGHINI: | ||
| 18707 | |||
| 18708 | // Could theoretically have their Z set by a script | ||
| 18709 | case eeFIRE: | ||
| 18710 | 138257 | return true; | |
| 18711 | break; | ||
| 18712 | } | ||
| 18713 | |||
| 18714 | 1155492 | return false; | |
| 18715 | 1293749 | } | |
| 18716 | |||
| 18717 | // Can't have Z position | ||
| 18718 | 12451 | bool never_in_air(int32_t id) | |
| 18719 | { | ||
| 18720 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12451 times.
|
12451 | if( ((unsigned)(id&0xFFF)) > MAXGUYS ) |
| 18721 | { | ||
| 18722 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()"); | ||
| 18723 | ✗ | return false; | |
| 18724 | } | ||
| 18725 |
1/2✓ Branch 0 taken 12451 times.
✗ Branch 1 not taken.
|
12451 | switch(guysbuf[id&0xFFF].family) |
| 18726 | { | ||
| 18727 | case eeMANHAN: | ||
| 18728 | case eeMOLD: | ||
| 18729 | case eeLANM: | ||
| 18730 | case eeGLEEOK: | ||
| 18731 | case eeZORA: | ||
| 18732 | case eeLEV: | ||
| 18733 | case eeAQUA: | ||
| 18734 | case eeROCK: | ||
| 18735 | case eeGANON: | ||
| 18736 | case eeTRAP: | ||
| 18737 | case eePROJECTILE: | ||
| 18738 | case eeSPINTILE: | ||
| 18739 | ✗ | return true; | |
| 18740 | } | ||
| 18741 | |||
| 18742 | 12451 | return false; | |
| 18743 | 12451 | } | |
| 18744 | |||
| 18745 | 6041 | bool canfall(int32_t id) | |
| 18746 | { | ||
| 18747 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6041 times.
|
6041 | if( ((unsigned)(id&0xFFF)) > MAXGUYS ) |
| 18748 | { | ||
| 18749 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()"); | ||
| 18750 | ✗ | return false; | |
| 18751 | } | ||
| 18752 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 6041 times.
✗ Branch 2 not taken.
|
6041 | switch(guysbuf[id&0xFFF].family) |
| 18753 | { | ||
| 18754 | case eeGUY: | ||
| 18755 | { | ||
| 18756 | ✗ | if(id < eOCTO1S) | |
| 18757 | ✗ | return false; | |
| 18758 | |||
| 18759 | ✗ | switch(guysbuf[id&0xFFF].misc10) | |
| 18760 | { | ||
| 18761 | case 1: | ||
| 18762 | case 2: | ||
| 18763 | ✗ | return true; | |
| 18764 | |||
| 18765 | case 0: | ||
| 18766 | ✗ | case 3: | |
| 18767 | default: | ||
| 18768 | ✗ | return false; | |
| 18769 | } | ||
| 18770 | |||
| 18771 | case eeGHOMA: | ||
| 18772 | case eeDIG: | ||
| 18773 | ✗ | return false; | |
| 18774 | } | ||
| 18775 | } | ||
| 18776 | |||
| 18777 | |||
| 18778 |
2/4✓ Branch 0 taken 6041 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6041 times.
|
6041 | return !never_in_air(id) && !isflier(id) && !isjumper(id); |
| 18779 | 6041 | } | |
| 18780 | |||
| 18781 | 1182090 | bool enemy::enemycanfall(int32_t id, bool checkgrav) | |
| 18782 | { | ||
| 18783 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1182090 times.
|
1182090 | if( ((unsigned)(id&0xFFF)) > MAXGUYS ) |
| 18784 | { | ||
| 18785 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()"); | ||
| 18786 | ✗ | return false; | |
| 18787 | } | ||
| 18788 | //Z_scripterrlog("canfall family is %d:\n", family); | ||
| 18789 | //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false"); | ||
| 18790 | //if ( family == eeFIRE && id >= eSTART ) | ||
| 18791 | //{ | ||
| 18792 | // Z_scripterrlog("eeFire\n"); | ||
| 18793 | // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z | ||
| 18794 | //} | ||
| 18795 | |||
| 18796 | //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'. | ||
| 18797 | |||
| 18798 |
3/3✓ Branch 0 taken 2848 times.
✓ Branch 1 taken 1096540 times.
✓ Branch 2 taken 82702 times.
|
1182090 | switch(guysbuf[id&0xFFF].family) |
| 18799 | { | ||
| 18800 | case eeGUY: | ||
| 18801 | { | ||
| 18802 |
1/2✓ Branch 0 taken 82702 times.
✗ Branch 1 not taken.
|
82702 | if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall |
| 18803 | 82702 | return false; | |
| 18804 | |||
| 18805 | ✗ | switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z | |
| 18806 | { | ||
| 18807 | case 1: | ||
| 18808 | case 2: | ||
| 18809 | ✗ | return true; | |
| 18810 | |||
| 18811 | case 0: | ||
| 18812 | ✗ | case 3: | |
| 18813 | default: | ||
| 18814 | ✗ | return false; | |
| 18815 | } | ||
| 18816 | |||
| 18817 | case eeGHOMA: | ||
| 18818 | case eeDIG: | ||
| 18819 | 2848 | return false; | |
| 18820 | } | ||
| 18821 | } | ||
| 18822 | |||
| 18823 |
2/2✓ Branch 0 taken 815579 times.
✓ Branch 1 taken 280961 times.
|
1096540 | if(!checkgrav) return true; |
| 18824 | 815579 | return (moveflags & FLAG_OBEYS_GRAV); | |
| 18825 | |||
| 18826 | // if ( isflier(id) || isjumper(id) || never_in_air(id) ) | ||
| 18827 | // { | ||
| 18828 | // if ( moveflags & FLAG_OBEYS_GRAV ) return true; | ||
| 18829 | // else return false; | ||
| 18830 | // } | ||
| 18831 | // else | ||
| 18832 | // { | ||
| 18833 | // return (moveflags & FLAG_OBEYS_GRAV); | ||
| 18834 | // } | ||
| 18835 | //return !never_in_air(id) && !isflier(id) && !isjumper(id); | ||
| 18836 | 1182090 | } | |
| 18837 | |||
| 18838 | 73 | void addfires() | |
| 18839 | { | ||
| 18840 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 52 times.
|
73 | if(!get_qr(qr_NOGUYFIRES)) |
| 18841 | { | ||
| 18842 | 52 | int32_t bs = get_qr(qr_BSZELDA); | |
| 18843 | 52 | addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr); | |
| 18844 | 52 | addguy(bs?176:168,64,gFIRE,-18,false,nullptr); | |
| 18845 | 52 | } | |
| 18846 | 73 | } | |
| 18847 | |||
| 18848 | 1714 | void loadguys() | |
| 18849 | { | ||
| 18850 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1714 times.
|
1714 | if(loaded_guys) |
| 18851 | ✗ | return; | |
| 18852 | |||
| 18853 | 1714 | loaded_guys=true; | |
| 18854 | |||
| 18855 | 1714 | byte Guy=0; | |
| 18856 | // When in caves/item rooms, use mSPECIALITEM and ipONETIME2 | ||
| 18857 | // Else use mITEM and ipONETIME | ||
| 18858 | 1714 | int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM; | |
| 18859 | 1714 | int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME; | |
| 18860 | |||
| 18861 | 1714 | repaircharge=0; | |
| 18862 | 1714 | adjustmagic=false; | |
| 18863 | 1714 | learnslash=false; | |
| 18864 | |||
| 18865 |
2/2✓ Branch 0 taken 5142 times.
✓ Branch 1 taken 1714 times.
|
6856 | for(int32_t i=0; i<3; i++) |
| 18866 | { | ||
| 18867 | 5142 | prices[i]=0; | |
| 18868 | 5142 | } | |
| 18869 | |||
| 18870 | 1714 | hasitem=0; | |
| 18871 | |||
| 18872 | 1714 | mapscr* guyscr = tmpscr; | |
| 18873 |
4/4✓ Branch 0 taken 61 times.
✓ Branch 1 taken 1653 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 34 times.
|
1714 | if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES) |
| 18874 | { | ||
| 18875 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
|
34 | if(DMaps[currdmap].flags&dmfCAVES) |
| 18876 | { | ||
| 18877 | 34 | Guy=tmpscr[1].guy; | |
| 18878 | 34 | guyscr = tmpscr+1; | |
| 18879 | 34 | } | |
| 18880 | 34 | } | |
| 18881 | else | ||
| 18882 | { | ||
| 18883 | 1680 | Guy=tmpscr->guy; | |
| 18884 | |||
| 18885 |
4/4✓ Branch 0 taken 1653 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 1313 times.
✓ Branch 3 taken 340 times.
|
1680 | if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP)) |
| 18886 | 340 | game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited | |
| 18887 | } | ||
| 18888 | |||
| 18889 | 1714 | bool oldguy = get_qr(qr_OLD_GUY_HANDLING); | |
| 18890 | // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'. | ||
| 18891 |
4/4✓ Branch 0 taken 374 times.
✓ Branch 1 taken 1340 times.
✓ Branch 2 taken 299 times.
✓ Branch 3 taken 75 times.
|
1714 | if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES))) |
| 18892 | { | ||
| 18893 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 73 times.
|
75 | if(tmpscr->room==rZELDA) |
| 18894 | { | ||
| 18895 | 2 | addguy(120,72,Guy,-15,true,guyscr); | |
| 18896 | 2 | guys.spr(0)->hxofs=1000; | |
| 18897 | 2 | addenemy(128,96,eFIRE,-15); | |
| 18898 | 2 | addenemy(112,96,eFIRE,-15); | |
| 18899 | 2 | addenemy(96,120,eFIRE,-15); | |
| 18900 | 2 | addenemy(144,120,eFIRE,-15); | |
| 18901 | 2 | return; | |
| 18902 | } | ||
| 18903 | |||
| 18904 |
1/2✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
|
146 | bool ffire = oldguy |
| 18905 |
1/2✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
|
73 | ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES)) |
| 18906 | ✗ | : (guyscr->roomflags&RFL_GUYFIRES); | |
| 18907 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
|
73 | if(ffire) |
| 18908 | 73 | addfires(); | |
| 18909 | |||
| 18910 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 34 times.
|
73 | if(currscr>=128) |
| 18911 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
34 | if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN)) |
| 18912 | ✗ | Guy=0; | |
| 18913 | |||
| 18914 |
3/6✓ Branch 0 taken 8 times.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
|
73 | switch(tmpscr->room) |
| 18915 | { | ||
| 18916 | case rSP_ITEM: | ||
| 18917 | case rGRUMBLE: | ||
| 18918 | case rBOMBS: | ||
| 18919 | case rARROWS: | ||
| 18920 | case rSWINDLE: | ||
| 18921 | case rMUPGRADE: | ||
| 18922 | case rLEARNSLASH: | ||
| 18923 | case rTAKEONE: | ||
| 18924 |
8/8✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 3 times.
|
8 | if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW) |
| 18925 | 2 | Guy=0; | |
| 18926 | |||
| 18927 | 10 | break; | |
| 18928 | |||
| 18929 | case rREPAIR: | ||
| 18930 | ✗ | if (get_qr(qr_OLD_DOORREPAIR)) break; | |
| 18931 | ✗ | if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW) | |
| 18932 | ✗ | Guy=0; | |
| 18933 | |||
| 18934 | ✗ | break; | |
| 18935 | case rRP_HC: | ||
| 18936 | ✗ | if (get_qr(qr_OLD_POTION_OR_HC)) break; | |
| 18937 | ✗ | if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW) | |
| 18938 | ✗ | Guy=0; | |
| 18939 | |||
| 18940 | ✗ | break; | |
| 18941 | case rMONEY: | ||
| 18942 | ✗ | if (get_qr(qr_OLD_SECRETMONEY)) break; | |
| 18943 | ✗ | if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW) | |
| 18944 | ✗ | Guy=0; | |
| 18945 | |||
| 18946 | ✗ | break; | |
| 18947 | |||
| 18948 | case rTRIFORCE: | ||
| 18949 | { | ||
| 18950 | 6 | int32_t tc = TriforceCount(); | |
| 18951 | |||
| 18952 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
|
6 | if(get_qr(qr_4TRI)) |
| 18953 | { | ||
| 18954 |
1/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if((get_qr(qr_3TRI) && tc>=3) || tc>=4) |
| 18955 | 1 | Guy=0; | |
| 18956 | 1 | } | |
| 18957 | else | ||
| 18958 | { | ||
| 18959 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | if((get_qr(qr_3TRI) && tc>=6) || tc>=8) |
| 18960 | 5 | Guy=0; | |
| 18961 | } | ||
| 18962 | } | ||
| 18963 | 6 | break; | |
| 18964 | } | ||
| 18965 | |||
| 18966 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 65 times.
|
73 | if(Guy) |
| 18967 | { | ||
| 18968 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
|
65 | if(ffire) |
| 18969 | 65 | blockpath=true; | |
| 18970 | |||
| 18971 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 31 times.
|
65 | if(currscr<128) |
| 18972 | 31 | sfx(WAV_SCALE); | |
| 18973 | |||
| 18974 |
4/4✓ Branch 0 taken 40 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 31 times.
|
65 | addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr); |
| 18975 | 65 | Hero.Freeze(); | |
| 18976 | 65 | } | |
| 18977 | 73 | } | |
| 18978 |
5/6✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1603 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
|
1639 | else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag |
| 18979 | { | ||
| 18980 | 3 | sfx(WAV_SCALE); | |
| 18981 | 3 | addguy(120,62,Guy,-14,false,guyscr); | |
| 18982 | 3 | } | |
| 18983 | |||
| 18984 | 1712 | loaditem(); | |
| 18985 | |||
| 18986 | // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if | ||
| 18987 | // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does. | ||
| 18988 |
3/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
1712 | if(tmpscr->room==r10RUPIES && !getmapflag(mf)) |
| 18989 | { | ||
| 18990 | //setmapflag(); | ||
| 18991 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 2 times.
|
22 | for(int32_t i=0; i<10; i++) |
| 18992 | 20 | additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14); | |
| 18993 | 2 | } | |
| 18994 | 1714 | } | |
| 18995 | |||
| 18996 | 1714 | void loaditem() | |
| 18997 | { | ||
| 18998 | 1714 | byte Item = 0; | |
| 18999 | |||
| 19000 |
2/2✓ Branch 0 taken 1653 times.
✓ Branch 1 taken 61 times.
|
1714 | if(currscr<128) |
| 19001 | { | ||
| 19002 | 1653 | Item=tmpscr->item; | |
| 19003 | |||
| 19004 |
4/4✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1618 times.
✓ Branch 2 taken 1496 times.
✓ Branch 3 taken 157 times.
|
1653 | if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0)) |
| 19005 | { | ||
| 19006 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 155 times.
|
157 | if(tmpscr->flags8&fSECRETITEM) |
| 19007 | 2 | hasitem=8; | |
| 19008 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 83 times.
|
155 | else if(tmpscr->flags&fITEM) |
| 19009 | 72 | hasitem=1; | |
| 19010 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 75 times.
|
83 | else if(tmpscr->enemyflags&efCARRYITEM) |
| 19011 | 8 | hasitem=4; // Will be set to 2 by roaming_item | |
| 19012 | else | ||
| 19013 |
2/4✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
|
150 | items.add(new item((zfix)tmpscr->itemx, |
| 19014 |
3/12✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 75 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 75 times.
✗ Branch 11 not taken.
|
75 | (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1), |
| 19015 |
2/10✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 75 times.
✗ Branch 9 not taken.
|
75 | (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0, |
| 19016 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 60 times.
|
75 | Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece || |
| 19017 | 75 | (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0)); | |
| 19018 | 157 | } | |
| 19019 | 1653 | } | |
| 19020 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 27 times.
|
61 | else if(!(DMaps[currdmap].flags&dmfCAVES)) |
| 19021 | { | ||
| 19022 |
2/6✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
27 | if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM |
| 19023 |
3/4✓ Branch 0 taken 7 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
|
27 | && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS))) |
| 19024 | { | ||
| 19025 | 7 | Item=tmpscr[1].catchall; | |
| 19026 | |||
| 19027 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | if(Item) |
| 19028 |
2/4✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
14 | items.add(new item((zfix)tmpscr->itemx, |
| 19029 |
3/12✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
|
7 | (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1), |
| 19030 |
2/10✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
|
7 | (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0, |
| 19031 | 7 | Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0)); | |
| 19032 | 7 | } | |
| 19033 | 27 | } | |
| 19034 | 1714 | } | |
| 19035 | |||
| 19036 | 26 | void never_return(int32_t index) | |
| 19037 | { | ||
| 19038 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 25 times.
|
26 | if(!get_qr(qr_KILLALL)) |
| 19039 | 25 | goto doit; | |
| 19040 | |||
| 19041 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for(int32_t i=0; i<guys.Count(); i++) |
| 19042 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
2 | if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index) |
| 19043 | { | ||
| 19044 | ✗ | goto dontdoit; | |
| 19045 | 1 | } | |
| 19046 | |||
| 19047 | doit: | ||
| 19048 | 26 | setmapflag(mNEVERRET); | |
| 19049 | dontdoit: | ||
| 19050 | 26 | return; | |
| 19051 | } | ||
| 19052 | |||
| 19053 | 2044 | bool slowguy(int32_t id) | |
| 19054 | { | ||
| 19055 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2044 times.
|
2044 | if( ((unsigned)(id&0xFFF)) > MAXGUYS ) |
| 19056 | { | ||
| 19057 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()"); | ||
| 19058 | ✗ | return false; | |
| 19059 | } | ||
| 19060 | //return (guysbuf[id].step<100); | ||
| 19061 |
2/2✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 547 times.
|
2044 | switch(id) |
| 19062 | { | ||
| 19063 | case eOCTO1S: | ||
| 19064 | case eOCTO2S: | ||
| 19065 | case eOCTO1F: | ||
| 19066 | case eOCTO2F: | ||
| 19067 | case eLEV1: | ||
| 19068 | case eLEV2: | ||
| 19069 | case eROCK: | ||
| 19070 | case eBOULDER: | ||
| 19071 | 547 | return true; | |
| 19072 | } | ||
| 19073 | |||
| 19074 | 1497 | return false; | |
| 19075 | 2044 | } | |
| 19076 | |||
| 19077 | 2457 | bool ok2add(int32_t id) | |
| 19078 | { | ||
| 19079 |
2/4✓ Branch 0 taken 2457 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2457 times.
|
2457 | if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0) |
| 19080 | { | ||
| 19081 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()"); | ||
| 19082 | ✗ | return false; | |
| 19083 | } | ||
| 19084 |
4/4✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2433 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 18 times.
|
2457 | if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret)) |
| 19085 | 18 | return false; | |
| 19086 | |||
| 19087 |
4/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2431 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
|
2439 | switch(guysbuf[id].family) |
| 19088 | { | ||
| 19089 | // I added a special case for shooters because having traps on the same screen | ||
| 19090 | // was preventing them from spawning due to TMPNORET. This means they will | ||
| 19091 | // never stay dead, though, so it may not be the best solution. - Saf | ||
| 19092 | case eePROJECTILE: | ||
| 19093 | 1 | return true; | |
| 19094 | |||
| 19095 | |||
| 19096 | case eeDIG: | ||
| 19097 | { | ||
| 19098 |
1/3✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | switch(guysbuf[id].misc10) |
| 19099 | { | ||
| 19100 | case 1: | ||
| 19101 | ✗ | if(!get_qr(qr_NOTMPNORET)) | |
| 19102 | ✗ | return !getmapflag(mTMPNORET); | |
| 19103 | |||
| 19104 | ✗ | return true; | |
| 19105 | |||
| 19106 | 3 | case 0: | |
| 19107 | default: | ||
| 19108 | 3 | return true; | |
| 19109 | } | ||
| 19110 | } | ||
| 19111 | case eeGANON: | ||
| 19112 | case eeTRAP: | ||
| 19113 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
8 | if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON)) |
| 19114 |
4/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
|
4 | || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false; |
| 19115 | [[fallthrough]]; | ||
| 19116 | default: | ||
| 19117 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2431 times.
|
2431 | if (guysbuf[id].flags2&guy_ignoretmpnr) return true; |
| 19118 | 2431 | break; | |
| 19119 | } | ||
| 19120 | |||
| 19121 |
2/2✓ Branch 0 taken 214 times.
✓ Branch 1 taken 2217 times.
|
2431 | if(!get_qr(qr_NOTMPNORET)) |
| 19122 | 2217 | return !getmapflag(mTMPNORET); | |
| 19123 | |||
| 19124 | 214 | return true; | |
| 19125 | 2457 | } | |
| 19126 | |||
| 19127 | 210689 | void activate_fireball_statue(int32_t pos) | |
| 19128 | { | ||
| 19129 |
3/4✓ Branch 0 taken 3176 times.
✓ Branch 1 taken 207513 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3176 times.
|
210689 | if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0) |
| 19130 | { | ||
| 19131 | 207513 | return; | |
| 19132 | } | ||
| 19133 | |||
| 19134 | 3176 | int32_t cx=-1000, cy=-1000; | |
| 19135 | 3176 | int32_t x = (pos&15)<<4; | |
| 19136 | 3176 | int32_t y = pos&0xF0; | |
| 19137 | |||
| 19138 | 3176 | int32_t ctype = combobuf[MAPCOMBO(x,y)].type; | |
| 19139 | |||
| 19140 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3176 times.
|
3176 | if(!isfixedtogrid(statueID)) |
| 19141 | { | ||
| 19142 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3144 times.
|
3176 | if(ctype==cL_STATUE) |
| 19143 | { | ||
| 19144 | 32 | cx=x+4; | |
| 19145 | 32 | cy=y+7; | |
| 19146 | 32 | } | |
| 19147 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3112 times.
|
3144 | else if(ctype==cR_STATUE) |
| 19148 | { | ||
| 19149 | 32 | cx=x-8; | |
| 19150 | 32 | cy=y-1; | |
| 19151 | 32 | } | |
| 19152 |
2/2✓ Branch 0 taken 3106 times.
✓ Branch 1 taken 6 times.
|
3112 | else if(ctype==cC_STATUE) |
| 19153 | { | ||
| 19154 | 6 | cx=x; | |
| 19155 | 6 | cy=y; | |
| 19156 | 6 | } | |
| 19157 | 3176 | } | |
| 19158 | ✗ | else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE) | |
| 19159 | { | ||
| 19160 | ✗ | cx=x; | |
| 19161 | ✗ | cy=y; | |
| 19162 | ✗ | } | |
| 19163 | |||
| 19164 |
2/2✓ Branch 0 taken 3106 times.
✓ Branch 1 taken 70 times.
|
3176 | if(cx!=-1000) // No point creating it if this is false |
| 19165 | { | ||
| 19166 |
2/2✓ Branch 0 taken 188 times.
✓ Branch 1 taken 70 times.
|
258 | for(int32_t j=0; j<guys.Count(); j++) |
| 19167 | { | ||
| 19168 |
3/4✓ Branch 0 taken 40 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
|
188 | if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy)) |
| 19169 | { | ||
| 19170 | ✗ | if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here! | |
| 19171 | ✗ | return; // No point deleting it. A script might be toying with it in some way. | |
| 19172 | else | ||
| 19173 | ✗ | guys.del(j); | |
| 19174 | ✗ | } | |
| 19175 | 188 | } | |
| 19176 | |||
| 19177 | 70 | addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0); | |
| 19178 | 70 | } | |
| 19179 | 210689 | } | |
| 19180 | |||
| 19181 | 1689 | void activate_fireball_statues() | |
| 19182 | { | ||
| 19183 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1671 times.
|
1689 | if(!(tmpscr->enemyflags&efFIREBALLS)) |
| 19184 | { | ||
| 19185 | 1671 | return; | |
| 19186 | } | ||
| 19187 | |||
| 19188 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 3168 times.
|
3186 | for(int32_t i=0; i<176; i++) |
| 19189 | { | ||
| 19190 | 3168 | activate_fireball_statue(i); | |
| 19191 | 3168 | } | |
| 19192 | 1689 | } | |
| 19193 | |||
| 19194 | 1689 | void load_default_enemies() | |
| 19195 | { | ||
| 19196 | 1689 | wallm_load_clk=frame-80; | |
| 19197 | |||
| 19198 |
2/2✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 93 times.
|
1689 | if(tmpscr->enemyflags&efZORA) |
| 19199 | { | ||
| 19200 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
|
93 | if(zoraID>=0) |
| 19201 | 93 | addenemy(-16, -16, zoraID, 0); | |
| 19202 | 93 | } | |
| 19203 | |||
| 19204 |
2/2✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 9 times.
|
1689 | if(tmpscr->enemyflags&efTRAP4) |
| 19205 | { | ||
| 19206 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
|
9 | if(cornerTrapID>=0) |
| 19207 | { | ||
| 19208 | 9 | addenemy(32, 32, cornerTrapID, -14); | |
| 19209 | 9 | addenemy(208, 32, cornerTrapID, -14); | |
| 19210 | 9 | addenemy(32, 128, cornerTrapID, -14); | |
| 19211 | 9 | addenemy(208, 128, cornerTrapID, -14); | |
| 19212 | 9 | } | |
| 19213 | 9 | } | |
| 19214 | |||
| 19215 |
2/2✓ Branch 0 taken 18579 times.
✓ Branch 1 taken 1689 times.
|
20268 | for(int32_t y=0; y<176; y+=16) |
| 19216 | { | ||
| 19217 |
2/2✓ Branch 0 taken 297264 times.
✓ Branch 1 taken 18579 times.
|
315843 | for(int32_t x=0; x<256; x+=16) |
| 19218 | { | ||
| 19219 | 297264 | int32_t ctype = combobuf[MAPCOMBO(x,y)].type; | |
| 19220 | 297264 | int32_t cflag = MAPFLAG(x, y); | |
| 19221 | 297264 | int32_t cflag_i = MAPCOMBOFLAG(x, y); | |
| 19222 | |||
| 19223 |
4/6✓ Branch 0 taken 297264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297258 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 297258 times.
|
297264 | if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H) |
| 19224 | { | ||
| 19225 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(trapLOSHorizontalID>=0) |
| 19226 | 6 | addenemy(x, y, trapLOSHorizontalID, -14); | |
| 19227 | 6 | } | |
| 19228 |
3/6✓ Branch 0 taken 297258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297258 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 297258 times.
|
297258 | else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V) |
| 19229 | { | ||
| 19230 | ✗ | if(trapLOSVerticalID>=0) | |
| 19231 | ✗ | addenemy(x, y, trapLOSVerticalID, -14); | |
| 19232 | ✗ | } | |
| 19233 |
4/6✓ Branch 0 taken 297258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297254 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 297254 times.
|
297258 | else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4) |
| 19234 | { | ||
| 19235 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if(trapLOS4WayID>=0) |
| 19236 | { | ||
| 19237 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if(addenemy(x, y, trapLOS4WayID, -14)) |
| 19238 | 4 | guys.spr(guys.Count()-1)->dummy_int[1]=2; | |
| 19239 | 4 | } | |
| 19240 | 4 | } | |
| 19241 | |||
| 19242 |
4/6✓ Branch 0 taken 297254 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297252 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 297252 times.
|
297254 | else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR) |
| 19243 | { | ||
| 19244 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(trapConstantHorizontalID>=0) |
| 19245 | 2 | addenemy(x, y, trapConstantHorizontalID, -14); | |
| 19246 | 2 | } | |
| 19247 |
4/6✓ Branch 0 taken 297252 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297250 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 297250 times.
|
297252 | else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD) |
| 19248 | { | ||
| 19249 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(trapConstantVerticalID>=0) |
| 19250 | 2 | addenemy(x, y, trapConstantVerticalID, -14); | |
| 19251 | 2 | } | |
| 19252 | |||
| 19253 |
1/2✓ Branch 0 taken 297264 times.
✗ Branch 1 not taken.
|
297264 | if(ctype==cSPINTILE1) |
| 19254 | { | ||
| 19255 | // Awaken spinning tile | ||
| 19256 | ✗ | awaken_spinning_tile(tmpscr,COMBOPOS(x,y)); | |
| 19257 | ✗ | } | |
| 19258 | 297264 | } | |
| 19259 | 18579 | } | |
| 19260 | |||
| 19261 |
2/2✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1 times.
|
1689 | if(tmpscr->enemyflags&efTRAP2) |
| 19262 | { | ||
| 19263 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(centerTrapID>=-1) |
| 19264 | { | ||
| 19265 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(addenemy(64, 80, centerTrapID, -14)) |
| 19266 | 1 | guys.spr(guys.Count()-1)->dummy_int[1]=1; | |
| 19267 | |||
| 19268 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if(addenemy(176, 80, centerTrapID, -14)) |
| 19269 | 1 | guys.spr(guys.Count()-1)->dummy_int[1]=1; | |
| 19270 | 1 | } | |
| 19271 | 1 | } | |
| 19272 | |||
| 19273 |
2/2✓ Branch 0 taken 1683 times.
✓ Branch 1 taken 6 times.
|
1689 | if(tmpscr->enemyflags&efROCKS) |
| 19274 | { | ||
| 19275 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | if(rockID>=0) |
| 19276 | { | ||
| 19277 | 6 | addenemy(zc_oldrand()&0xF0, 0, rockID, 0); | |
| 19278 | 6 | addenemy(zc_oldrand()&0xF0, 0, rockID, 0); | |
| 19279 | 6 | addenemy(zc_oldrand()&0xF0, 0, rockID, 0); | |
| 19280 | 6 | } | |
| 19281 | 6 | } | |
| 19282 | |||
| 19283 | 1689 | activate_fireball_statues(); | |
| 19284 | 1689 | } | |
| 19285 | |||
| 19286 | 2360988 | void update_slope_combopos(int32_t lyr, int32_t pos) | |
| 19287 | { | ||
| 19288 |
2/4✓ Branch 0 taken 2360988 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2360988 times.
|
2360988 | if(unsigned(lyr) > 6 || unsigned(pos) > 175) return; |
| 19289 | 2360988 | mapscr* s = FFCore.tempScreens[lyr]; | |
| 19290 | 2360988 | newcombo const& cmb = combobuf[s->data[pos]]; | |
| 19291 | |||
| 19292 | 2360988 | auto id = (176*lyr)+pos; | |
| 19293 | 2360988 | auto it = slopes.find(id); | |
| 19294 | |||
| 19295 | 2360988 | bool wasSlope = it!=slopes.end(); | |
| 19296 | 2360988 | bool isSlope = cmb.type == cSLOPE; | |
| 19297 | |||
| 19298 |
3/4✓ Branch 0 taken 188 times.
✓ Branch 1 taken 2360800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
|
2360988 | if(isSlope && !wasSlope) |
| 19299 | { | ||
| 19300 | 188 | slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos); | |
| 19301 | 188 | } | |
| 19302 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2360800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2360800 | else if(wasSlope && !isSlope) |
| 19303 | { | ||
| 19304 | ✗ | slopes.erase(it); | |
| 19305 | ✗ | } | |
| 19306 | 2360988 | } | |
| 19307 | 1749 | void update_slope_comboposes() | |
| 19308 | { | ||
| 19309 |
2/2✓ Branch 0 taken 12243 times.
✓ Branch 1 taken 1749 times.
|
13992 | for(auto lyr = 0; lyr < 7; ++lyr) |
| 19310 | { | ||
| 19311 |
2/2✓ Branch 0 taken 2154768 times.
✓ Branch 1 taken 12243 times.
|
2167011 | for(auto pos = 0; pos < 176; ++pos) |
| 19312 | 2154768 | update_slope_combopos(lyr,pos); | |
| 19313 | 12243 | } | |
| 19314 | 1749 | } | |
| 19315 | |||
| 19316 | // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type. | ||
| 19317 | // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L | ||
| 19318 | 207521 | void screen_combo_modify_preroutine(mapscr *s, int32_t pos) | |
| 19319 | { | ||
| 19320 | 207521 | delete_fireball_shooter(s, pos); | |
| 19321 | 207521 | } | |
| 19322 | |||
| 19323 | //Placeholder in case we need it. | ||
| 19324 | ✗ | void screen_ffc_modify_preroutine(word index) | |
| 19325 | { | ||
| 19326 | ✗ | return; | |
| 19327 | } | ||
| 19328 | |||
| 19329 | // Everything that must be done after we change a screen's combo to another combo. -L | ||
| 19330 | 207521 | void screen_combo_modify_postroutine(mapscr *s, int32_t pos) | |
| 19331 | { | ||
| 19332 | 207521 | s->valid |= mVALID; | |
| 19333 | 207521 | activate_fireball_statue(pos); | |
| 19334 | |||
| 19335 |
1/2✓ Branch 0 taken 207521 times.
✗ Branch 1 not taken.
|
207521 | if(combobuf[s->data[pos]].type==cSPINTILE1) |
| 19336 | { | ||
| 19337 | // Awaken spinning tile | ||
| 19338 | ✗ | awaken_spinning_tile(s,pos); | |
| 19339 | ✗ | } | |
| 19340 | 207521 | int32_t lyr = -1; | |
| 19341 |
2/2✓ Branch 0 taken 2794 times.
✓ Branch 1 taken 204727 times.
|
207521 | if(s == tmpscr) lyr = 0; |
| 19342 |
2/2✓ Branch 0 taken 1301 times.
✓ Branch 1 taken 9736 times.
|
11037 | else for(size_t q = 0; q < 6; ++q) |
| 19343 | { | ||
| 19344 |
2/2✓ Branch 0 taken 1493 times.
✓ Branch 1 taken 8243 times.
|
9736 | if(s == tmpscr2+q) |
| 19345 | { | ||
| 19346 | 1493 | lyr = q+1; | |
| 19347 | 1493 | break; | |
| 19348 | } | ||
| 19349 | 8243 | } | |
| 19350 |
2/2✓ Branch 0 taken 1301 times.
✓ Branch 1 taken 206220 times.
|
207521 | if(lyr > -1) |
| 19351 | 206220 | update_slope_combopos(lyr,pos); | |
| 19352 | 207521 | } | |
| 19353 | |||
| 19354 | 286323 | void screen_ffc_modify_postroutine(word index) | |
| 19355 | { | ||
| 19356 | 286323 | ffcdata& ff = tmpscr->ffcs[index]; | |
| 19357 | 286323 | newcombo const& cmb = combobuf[ff.data]; | |
| 19358 | |||
| 19359 | 286323 | auto id = (176*7)+int32_t(index); | |
| 19360 | 286323 | auto it = slopes.find(id); | |
| 19361 | |||
| 19362 | 286323 | bool wasSlope = it!=slopes.end(); | |
| 19363 |
1/2✓ Branch 0 taken 286323 times.
✗ Branch 1 not taken.
|
286323 | bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER); |
| 19364 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 286323 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
286323 | if(isSlope && !wasSlope) |
| 19365 | { | ||
| 19366 | ✗ | slopes.try_emplace(id, nullptr, &ff, id); | |
| 19367 | ✗ | } | |
| 19368 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 286323 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
286323 | else if(wasSlope && !isSlope) |
| 19369 | { | ||
| 19370 | ✗ | slopes.erase(it); | |
| 19371 | ✗ | } | |
| 19372 | |||
| 19373 | 286323 | tmpscr->ffcCountMarkDirty(); | |
| 19374 | 286323 | } | |
| 19375 | |||
| 19376 | 8 | void screen_combo_modify_pre(int32_t cid) | |
| 19377 | { | ||
| 19378 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 8 times.
|
64 | for(auto lyr = 0; lyr < 7; ++lyr) |
| 19379 | { | ||
| 19380 | 56 | mapscr* t = FFCore.tempScreens[lyr]; | |
| 19381 |
2/2✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 56 times.
|
9912 | for(int32_t i = 0; i < 176; i++) |
| 19382 | { | ||
| 19383 |
1/2✓ Branch 0 taken 9856 times.
✗ Branch 1 not taken.
|
9856 | if(t->data[i] == cid) |
| 19384 | { | ||
| 19385 | ✗ | screen_combo_modify_preroutine(t,i); | |
| 19386 | ✗ | } | |
| 19387 | 9856 | } | |
| 19388 | 56 | } | |
| 19389 | 8 | } | |
| 19390 | 8 | void screen_combo_modify_post(int32_t cid) | |
| 19391 | { | ||
| 19392 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 8 times.
|
64 | for(auto lyr = 0; lyr < 7; ++lyr) |
| 19393 | { | ||
| 19394 | 56 | mapscr* t = FFCore.tempScreens[lyr]; | |
| 19395 |
2/2✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 56 times.
|
9912 | for(int32_t i = 0; i < 176; i++) |
| 19396 | { | ||
| 19397 |
1/2✓ Branch 0 taken 9856 times.
✗ Branch 1 not taken.
|
9856 | if(t->data[i] == cid) |
| 19398 | { | ||
| 19399 | ✗ | screen_combo_modify_postroutine(t,i); | |
| 19400 | ✗ | } | |
| 19401 | 9856 | } | |
| 19402 | 56 | } | |
| 19403 |
2/2✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 8 times.
|
1032 | for(word ind = 0; ind < MAXFFCS; ++ind) |
| 19404 | { | ||
| 19405 |
1/2✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
|
1024 | if(tmpscr->ffcs[ind].data == cid) |
| 19406 | ✗ | screen_ffc_modify_postroutine(ind); | |
| 19407 | 1024 | } | |
| 19408 | 8 | } | |
| 19409 | |||
| 19410 | ✗ | void awaken_spinning_tile(mapscr *s, int32_t pos) | |
| 19411 | { | ||
| 19412 | ✗ | addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames)); | |
| 19413 | ✗ | } | |
| 19414 | |||
| 19415 | |||
| 19416 | // It stands for next_side_pos | ||
| 19417 | 1186 | void nsp(bool random) | |
| 19418 | // moves sle_x and sle_y to the next position | ||
| 19419 | { | ||
| 19420 |
2/2✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1042 times.
|
1186 | if(random) |
| 19421 | { | ||
| 19422 |
2/2✓ Branch 0 taken 68 times.
✓ Branch 1 taken 76 times.
|
144 | if(zc_oldrand()%2) |
| 19423 | { | ||
| 19424 | 68 | sle_x = (zc_oldrand()%2) ? 0 : 240; | |
| 19425 | 68 | sle_y = (zc_oldrand()%10)*16; | |
| 19426 | 68 | } | |
| 19427 | else | ||
| 19428 | { | ||
| 19429 | 76 | sle_y = (zc_oldrand()%2) ? 0 : 160; | |
| 19430 | 76 | sle_x = (zc_oldrand()%15)*16; | |
| 19431 | } | ||
| 19432 | |||
| 19433 | 144 | return; | |
| 19434 | } | ||
| 19435 | |||
| 19436 |
2/2✓ Branch 0 taken 727 times.
✓ Branch 1 taken 315 times.
|
1042 | if(sle_x==0) |
| 19437 | { | ||
| 19438 |
2/2✓ Branch 0 taken 289 times.
✓ Branch 1 taken 26 times.
|
315 | if(sle_y<160) |
| 19439 | 289 | sle_y+=16; | |
| 19440 | else | ||
| 19441 | 26 | sle_x+=16; | |
| 19442 | 315 | } | |
| 19443 |
2/2✓ Branch 0 taken 368 times.
✓ Branch 1 taken 359 times.
|
727 | else if(sle_y==160) |
| 19444 | { | ||
| 19445 |
2/2✓ Branch 0 taken 346 times.
✓ Branch 1 taken 22 times.
|
368 | if(sle_x<240) |
| 19446 | 346 | sle_x+=16; | |
| 19447 | else | ||
| 19448 | 22 | sle_y-=16; | |
| 19449 | 368 | } | |
| 19450 |
2/2✓ Branch 0 taken 183 times.
✓ Branch 1 taken 176 times.
|
359 | else if(sle_x==240) |
| 19451 | { | ||
| 19452 |
2/2✓ Branch 0 taken 167 times.
✓ Branch 1 taken 16 times.
|
183 | if(sle_y>0) |
| 19453 | 167 | sle_y-=16; | |
| 19454 | else | ||
| 19455 | 16 | sle_x-=16; | |
| 19456 | 183 | } | |
| 19457 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
|
176 | else if(sle_y==0) |
| 19458 | { | ||
| 19459 |
1/2✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
|
176 | if(sle_x>0) |
| 19460 | 176 | sle_x-=16; | |
| 19461 | else | ||
| 19462 | ✗ | sle_y+=16; | |
| 19463 | 176 | } | |
| 19464 | 1186 | } | |
| 19465 | |||
| 19466 | 293 | int32_t next_side_pos(bool random) | |
| 19467 | // moves sle_x and sle_y to the next available position | ||
| 19468 | // returns the direction the enemy should face | ||
| 19469 | { | ||
| 19470 | bool blocked; | ||
| 19471 | 293 | int32_t c=0; | |
| 19472 | |||
| 19473 | 293 | do | |
| 19474 | { | ||
| 19475 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
|
1186 | nsp(c>35 ? false : random); |
| 19476 |
3/4✓ Branch 0 taken 293 times.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 293 times.
|
1479 | blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) || |
| 19477 |
1/2✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
|
293 | (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies || |
| 19478 |
2/4✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 293 times.
✗ Branch 3 not taken.
|
293 | MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY || |
| 19479 |
2/4✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 293 times.
|
293 | MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY || |
| 19480 | 293 | iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true)); | |
| 19481 | |||
| 19482 |
1/2✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
|
1186 | if(++c>50) |
| 19483 | ✗ | return -1; | |
| 19484 |
2/2✓ Branch 0 taken 893 times.
✓ Branch 1 taken 293 times.
|
1186 | } |
| 19485 | 1186 | while(blocked); | |
| 19486 | |||
| 19487 | 293 | int32_t dir=0; | |
| 19488 | |||
| 19489 |
2/2✓ Branch 0 taken 226 times.
✓ Branch 1 taken 67 times.
|
293 | if(sle_x==0) dir=right; |
| 19490 | |||
| 19491 |
2/2✓ Branch 0 taken 217 times.
✓ Branch 1 taken 76 times.
|
293 | if(sle_y==0) dir=down; |
| 19492 | |||
| 19493 |
2/2✓ Branch 0 taken 187 times.
✓ Branch 1 taken 106 times.
|
293 | if(sle_x==240) dir=left; |
| 19494 | |||
| 19495 |
1/2✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
|
293 | if(sle_y==168) dir=up; |
| 19496 | |||
| 19497 | 293 | return dir; | |
| 19498 | 293 | } | |
| 19499 | |||
| 19500 | ✗ | bool can_side_load(int32_t id) | |
| 19501 | { | ||
| 19502 | ✗ | if( ((unsigned)(id&0xFFF)) > MAXGUYS ) | |
| 19503 | { | ||
| 19504 | //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()"); | ||
| 19505 | ✗ | return false; | |
| 19506 | } | ||
| 19507 | ✗ | switch(guysbuf[id].family) //id&0x0FFF) | |
| 19508 | { | ||
| 19509 | //case eTEK1: | ||
| 19510 | //case eTEK2: | ||
| 19511 | //case eTEK3: | ||
| 19512 | //case eLEV1: | ||
| 19513 | //case eLEV2: | ||
| 19514 | //case eLEV3: | ||
| 19515 | //case eRAQUAM: | ||
| 19516 | //case eLAQUAM: | ||
| 19517 | //case eDODONGO: | ||
| 19518 | //case eMANHAN: | ||
| 19519 | //case eGLEEOK1: | ||
| 19520 | //case eGLEEOK2: | ||
| 19521 | //case eGLEEOK3: | ||
| 19522 | //case eGLEEOK4: | ||
| 19523 | //case eDIG1: | ||
| 19524 | //case eDIG3: | ||
| 19525 | //case eGOHMA1: | ||
| 19526 | //case eGOHMA2: | ||
| 19527 | //case eCENT1: | ||
| 19528 | //case eCENT2: | ||
| 19529 | //case ePATRA1: | ||
| 19530 | //case ePATRA2: | ||
| 19531 | //case eGANON: | ||
| 19532 | //case eMANHAN2: | ||
| 19533 | //case eCEILINGM: later | ||
| 19534 | //case eFLOORM: later | ||
| 19535 | //case ePATRABS: | ||
| 19536 | //case ePATRAL2: | ||
| 19537 | //case ePATRAL3: | ||
| 19538 | //case eGLEEOK1F: | ||
| 19539 | //case eGLEEOK2F: | ||
| 19540 | //case eGLEEOK3F: | ||
| 19541 | //case eGLEEOK4F: | ||
| 19542 | //case eDODONGOBS: | ||
| 19543 | //case eDODONGOF: | ||
| 19544 | //case eGOHMA3: | ||
| 19545 | //case eGOHMA4: | ||
| 19546 | //case eSHOOTMAGIC: | ||
| 19547 | //case eSHOOTROCK: | ||
| 19548 | //case eSHOOTSPEAR: | ||
| 19549 | //case eSHOOTSWORD: | ||
| 19550 | //case eSHOOTFLAME: | ||
| 19551 | //case eSHOOTFLAME2: | ||
| 19552 | //case eSHOOTFBALL: | ||
| 19553 | case eeTEK: | ||
| 19554 | case eeLEV: | ||
| 19555 | case eeAQUA: | ||
| 19556 | case eeDONGO: | ||
| 19557 | case eeMANHAN: | ||
| 19558 | case eeGLEEOK: | ||
| 19559 | case eeDIG: | ||
| 19560 | case eeGHOMA: | ||
| 19561 | case eeLANM: | ||
| 19562 | case eePATRA: | ||
| 19563 | case eeGANON: | ||
| 19564 | case eePROJECTILE: | ||
| 19565 | ✗ | return false; | |
| 19566 | break; | ||
| 19567 | } | ||
| 19568 | |||
| 19569 | ✗ | return true; | |
| 19570 | ✗ | } | |
| 19571 | |||
| 19572 | static bool script_sle = false; | ||
| 19573 | static int32_t sle_pattern = 0; | ||
| 19574 | ✗ | void script_side_load_enemies() | |
| 19575 | { | ||
| 19576 | ✗ | if(script_sle || sle_clk) return; | |
| 19577 | ✗ | sle_cnt = 0; | |
| 19578 | ✗ | while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0) | |
| 19579 | ✗ | ++sle_cnt; | |
| 19580 | ✗ | script_sle = true; | |
| 19581 | ✗ | sle_pattern = tmpscr->pattern; | |
| 19582 | ✗ | sle_clk = 0; | |
| 19583 | ✗ | } | |
| 19584 | |||
| 19585 | 6623 | void side_load_enemies() | |
| 19586 | { | ||
| 19587 |
3/4✓ Branch 0 taken 6623 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6547 times.
✓ Branch 3 taken 76 times.
|
6623 | if(!script_sle && sle_clk==0) |
| 19588 | { | ||
| 19589 | 76 | sle_pattern = tmpscr->pattern; | |
| 19590 | 76 | sle_cnt = 0; | |
| 19591 | 76 | int32_t guycnt = 0; | |
| 19592 | 76 | int16_t s = (currmap<<7)+currscr; | |
| 19593 | 76 | bool beenhere=false; | |
| 19594 | 76 | bool reload=true; | |
| 19595 | 76 | bool unbeatablereload = true; | |
| 19596 | |||
| 19597 | 76 | load_default_enemies(); | |
| 19598 | |||
| 19599 |
2/2✓ Branch 0 taken 456 times.
✓ Branch 1 taken 76 times.
|
532 | for(int32_t i=0; i<6; i++) |
| 19600 |
2/2✓ Branch 0 taken 454 times.
✓ Branch 1 taken 2 times.
|
458 | if(visited[i]==s) |
| 19601 | 2 | beenhere=true; | |
| 19602 | |||
| 19603 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 74 times.
|
76 | if(!beenhere) |
| 19604 | { | ||
| 19605 | 74 | visited[vhead]=s; | |
| 19606 | 74 | vhead = (vhead+1)%6; | |
| 19607 | 74 | } | |
| 19608 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | else if(game->guys[s]==0) |
| 19609 | { | ||
| 19610 | ✗ | sle_cnt=0; | |
| 19611 | ✗ | reload=false; | |
| 19612 | ✗ | } | |
| 19613 | |||
| 19614 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
|
76 | if(reload) |
| 19615 | { | ||
| 19616 | 76 | sle_cnt = game->guys[s]; | |
| 19617 | |||
| 19618 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 45 times.
|
76 | if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere) |
| 19619 | 76 | || sle_cnt==0) | |
| 19620 | { | ||
| 19621 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 188 times.
✓ Branch 3 taken 45 times.
|
233 | while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0) |
| 19622 | 188 | ++sle_cnt; | |
| 19623 | 45 | } | |
| 19624 |
3/4✓ Branch 0 taken 74 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
|
76 | if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD)) |
| 19625 | { | ||
| 19626 | ✗ | for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++) | |
| 19627 | { | ||
| 19628 | ✗ | if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount)) | |
| 19629 | { | ||
| 19630 | ✗ | unbeatablereload = false; | |
| 19631 | ✗ | } | |
| 19632 | ✗ | } | |
| 19633 | ✗ | if (unbeatablereload) | |
| 19634 | { | ||
| 19635 | ✗ | while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0) | |
| 19636 | { | ||
| 19637 | ✗ | ++sle_cnt; | |
| 19638 | } | ||
| 19639 | ✗ | } | |
| 19640 | ✗ | } | |
| 19641 | 76 | } | |
| 19642 | |||
| 19643 |
2/4✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
|
76 | if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) |
| 19644 | { | ||
| 19645 | ✗ | sle_cnt = 0; | |
| 19646 | |||
| 19647 | ✗ | while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0) | |
| 19648 | ✗ | ++sle_cnt; | |
| 19649 | ✗ | } | |
| 19650 | |||
| 19651 |
2/2✓ Branch 0 taken 291 times.
✓ Branch 1 taken 76 times.
|
367 | for(int32_t i=0; i<sle_cnt; i++) |
| 19652 | 291 | ++guycnt; | |
| 19653 | |||
| 19654 | 76 | game->guys[s] = guycnt; | |
| 19655 | 76 | } | |
| 19656 | |||
| 19657 |
2/2✓ Branch 0 taken 6330 times.
✓ Branch 1 taken 293 times.
|
6623 | if((++sle_clk+8)%24 == 0) |
| 19658 | { | ||
| 19659 | 293 | int32_t dir = next_side_pos(sle_pattern==pSIDESR); | |
| 19660 | |||
| 19661 |
3/4✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 265 times.
|
293 | if(dir==-1 || tooclose(sle_x,sle_y,32)) |
| 19662 | { | ||
| 19663 | 28 | return; | |
| 19664 | } | ||
| 19665 | |||
| 19666 | 265 | int32_t enemy_slot=guys.Count(); | |
| 19667 | |||
| 19668 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 265 times.
|
265 | while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1])) |
| 19669 | ✗ | sle_cnt--; | |
| 19670 | |||
| 19671 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
|
265 | if(sle_cnt > 0) |
| 19672 | { | ||
| 19673 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
|
265 | if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0)) |
| 19674 | { | ||
| 19675 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
|
265 | if (((enemy*)guys.spr(enemy_slot))->family != eeTEK) |
| 19676 | { | ||
| 19677 | 265 | guys.spr(enemy_slot)->dir = dir; | |
| 19678 | 265 | } | |
| 19679 |
1/2✓ Branch 0 taken 265 times.
✗ Branch 1 not taken.
|
265 | if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME)) |
| 19680 | { | ||
| 19681 | ✗ | if (!FFCore.system_suspend[susptNPCSCRIPTS]) | |
| 19682 | { | ||
| 19683 | ✗ | guys.spr(enemy_slot)->run_script(MODE_NORMAL); | |
| 19684 | ✗ | ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true; | |
| 19685 | ✗ | } | |
| 19686 | ✗ | } | |
| 19687 | 265 | } | |
| 19688 | 265 | } | |
| 19689 | 265 | } | |
| 19690 | |||
| 19691 |
2/2✓ Branch 0 taken 6535 times.
✓ Branch 1 taken 60 times.
|
6595 | if(sle_cnt<=0) |
| 19692 | { | ||
| 19693 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
|
60 | if(script_sle) |
| 19694 | ✗ | script_sle = false; | |
| 19695 | 60 | else loaded_enemies=true; | |
| 19696 | 60 | sle_clk = 0; | |
| 19697 | 60 | } | |
| 19698 | 6623 | } | |
| 19699 | |||
| 19700 | 18239 | bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t) | |
| 19701 | { | ||
| 19702 | |||
| 19703 |
4/4✓ Branch 0 taken 16817 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 1422 times.
✓ Branch 3 taken 18239 times.
|
18239 | if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1). |
| 19704 | { | ||
| 19705 | //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]); | ||
| 19706 | 2844 | return false; //never 0, never OoB. | |
| 19707 | } | ||
| 19708 | // No corner enemies | ||
| 19709 |
6/6✓ Branch 0 taken 15948 times.
✓ Branch 1 taken 2291 times.
✓ Branch 2 taken 553 times.
✓ Branch 3 taken 16501 times.
✓ Branch 4 taken 1580 times.
✓ Branch 5 taken 1264 times.
|
18239 | if((x==0 || x==240) && (y==0 || y==160)) |
| 19710 | |||
| 19711 | 2844 | return false; | |
| 19712 | |||
| 19713 | //Is a no spawn combo... | ||
| 19714 |
3/4✓ Branch 0 taken 16497 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16497 times.
|
16501 | if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN) |
| 19715 | 4 | return false; | |
| 19716 | |||
| 19717 | // No enemies in dungeon walls | ||
| 19718 |
6/10✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 15235 times.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1262 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1262 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1262 times.
|
16497 | if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144)) |
| 19719 | ✗ | return false; | |
| 19720 | |||
| 19721 | // Too close | ||
| 19722 |
3/4✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 15332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1165 times.
|
16497 | if(tooclose(x,y,40) && t<11) |
| 19723 | 1165 | return false; | |
| 19724 | |||
| 19725 | // Can't fly onto it? | ||
| 19726 |
4/4✓ Branch 0 taken 385 times.
✓ Branch 1 taken 14947 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 115 times.
|
15469 | if(isflier(tmpscr->enemy[i])&& |
| 19727 |
2/2✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1 times.
|
385 | (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])|| |
| 19728 |
2/2✓ Branch 0 taken 137 times.
✓ Branch 1 taken 247 times.
|
384 | (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS)))) |
| 19729 | 116 | return false; | |
| 19730 | |||
| 19731 | // Can't jump onto it? | ||
| 19732 | if | ||
| 19733 | ( | ||
| 19734 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 883 times.
|
16099 | guysbuf[tmpscr->enemy[i]].family==eeTEK |
| 19735 | |||
| 19736 |
2/2✓ Branch 0 taken 883 times.
✓ Branch 1 taken 14333 times.
|
15216 | && |
| 19737 | ( | ||
| 19738 |
1/2✓ Branch 0 taken 883 times.
✗ Branch 1 not taken.
|
883 | COMBOTYPE(x+8,y+8)==cNOJUMPZONE|| |
| 19739 |
1/2✓ Branch 0 taken 883 times.
✗ Branch 1 not taken.
|
883 | COMBOTYPE(x+8,y+8)==cNOENEMY|| |
| 19740 |
1/2✓ Branch 0 taken 883 times.
✗ Branch 1 not taken.
|
883 | ispitfall(x+8,y+8)|| |
| 19741 |
1/2✓ Branch 0 taken 883 times.
✗ Branch 1 not taken.
|
883 | MAPFLAG(x+8,y+8)==mfNOENEMY|| |
| 19742 | 883 | MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY | |
| 19743 | ) | ||
| 19744 | ) | ||
| 19745 | { | ||
| 19746 | ✗ | return false; | |
| 19747 | } | ||
| 19748 | |||
| 19749 | // Other off-limit combos | ||
| 19750 |
6/6✓ Branch 0 taken 14947 times.
✓ Branch 1 taken 269 times.
✓ Branch 2 taken 14064 times.
✓ Branch 3 taken 883 times.
✓ Branch 4 taken 7482 times.
✓ Branch 5 taken 6582 times.
|
29280 | if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK && |
| 19751 |
2/2✓ Branch 0 taken 7529 times.
✓ Branch 1 taken 6535 times.
|
14064 | (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) && |
| 19752 | 14064 | guysbuf[tmpscr->enemy[i]].family!=eeZORA) | |
| 19753 | 6582 | return false; | |
| 19754 | |||
| 19755 | // Don't ever generate enemies on these combos! | ||
| 19756 |
2/4✓ Branch 0 taken 8634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8634 times.
|
8634 | if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE) |
| 19757 | ✗ | return false; | |
| 19758 | |||
| 19759 | //BS Dodongos need at least 2 spaces. | ||
| 19760 |
3/4✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8627 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
|
8634 | if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1)) |
| 19761 | { | ||
| 19762 | ✗ | if(((x<16) ||_walkflag(x-16,y+8, 2))&& | |
| 19763 | ✗ | ((x>224)||_walkflag(x+16,y+8, 2))&& | |
| 19764 | ✗ | ((y<16) ||_walkflag(x, y-8, 2))&& | |
| 19765 | ✗ | ((y>144)||_walkflag(x, y+24,2))) | |
| 19766 | { | ||
| 19767 | ✗ | return false; | |
| 19768 | } | ||
| 19769 | ✗ | } | |
| 19770 | |||
| 19771 | 8634 | return true; | |
| 19772 | 16817 | } | |
| 19773 | |||
| 19774 | 4328 | bool is_ceiling_pattern(int32_t i) | |
| 19775 | { | ||
| 19776 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4328 times.
|
4328 | return (i==pCEILING || i==pCEILINGR); |
| 19777 | } | ||
| 19778 | |||
| 19779 | 79 | int32_t placeenemy(int32_t i) | |
| 19780 | { | ||
| 19781 | 79 | std::map<int32_t, int32_t> freeposcache; | |
| 19782 | 79 | int32_t frees = 0; | |
| 19783 | |||
| 19784 |
2/2✓ Branch 0 taken 869 times.
✓ Branch 1 taken 79 times.
|
948 | for(int32_t y=0; y<176; y+=16) |
| 19785 | { | ||
| 19786 |
2/2✓ Branch 0 taken 13904 times.
✓ Branch 1 taken 869 times.
|
14773 | for(int32_t x=0; x<256; x+=16) |
| 19787 | { | ||
| 19788 |
3/4✓ Branch 0 taken 13904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6669 times.
✓ Branch 3 taken 7235 times.
|
13904 | if(is_starting_pos(i,x,y,0)) |
| 19789 | { | ||
| 19790 |
1/2✓ Branch 0 taken 6669 times.
✗ Branch 1 not taken.
|
6669 | freeposcache[frees++] = (y&0xF0)+(x>>4); |
| 19791 | 6669 | } | |
| 19792 | 13904 | } | |
| 19793 | 869 | } | |
| 19794 | |||
| 19795 |
1/2✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
|
79 | if(frees > 0) |
| 19796 |
2/4✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
|
79 | return freeposcache[zc_oldrand()%frees]; |
| 19797 | |||
| 19798 | ✗ | return -1; | |
| 19799 | 79 | } | |
| 19800 | |||
| 19801 | 2192 | void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt) | |
| 19802 | { | ||
| 19803 | 2192 | bool placed=false; | |
| 19804 | 2192 | int32_t t=-1; | |
| 19805 | |||
| 19806 | // First: enemy combo flags | ||
| 19807 |
2/2✓ Branch 0 taken 23366 times.
✓ Branch 1 taken 2044 times.
|
25410 | for(int32_t sy=0; sy<176; sy+=16) |
| 19808 | { | ||
| 19809 |
2/2✓ Branch 0 taken 372715 times.
✓ Branch 1 taken 23218 times.
|
395933 | for(int32_t sx=0; sx<256; sx+=16) |
| 19810 | { | ||
| 19811 | 372715 | int32_t cflag = MAPFLAG(sx, sy); | |
| 19812 | 372715 | int32_t cflag_i = MAPCOMBOFLAG(sx, sy); | |
| 19813 | |||
| 19814 |
2/4✓ Branch 0 taken 372715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 372715 times.
✗ Branch 3 not taken.
|
372715 | if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed)) |
| 19815 | { | ||
| 19816 | ✗ | if(!ok2add(tmpscr->enemy[i])) | |
| 19817 | { | ||
| 19818 | ✗ | if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt; | |
| 19819 | ✗ | } | |
| 19820 | else | ||
| 19821 | { | ||
| 19822 | ✗ | addenemy(sx, | |
| 19823 | ✗ | (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy, | |
| 19824 | ✗ | (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15); | |
| 19825 | |||
| 19826 | ✗ | ++guycnt; | |
| 19827 | |||
| 19828 | ✗ | placed=true; | |
| 19829 | ✗ | goto placed_enemy; | |
| 19830 | } | ||
| 19831 | ✗ | } | |
| 19832 | |||
| 19833 |
4/4✓ Branch 0 taken 372567 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 372567 times.
✓ Branch 3 taken 148 times.
|
372715 | else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed)) |
| 19834 | { | ||
| 19835 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
|
148 | if(!ok2add(tmpscr->enemy[i])) |
| 19836 | { | ||
| 19837 | ✗ | if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt; | |
| 19838 | ✗ | } | |
| 19839 | else | ||
| 19840 | { | ||
| 19841 | 296 | addenemy(sx, | |
| 19842 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
148 | (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy, |
| 19843 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
148 | (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15); |
| 19844 | |||
| 19845 | 148 | ++guycnt; | |
| 19846 | |||
| 19847 | 148 | placed=true; | |
| 19848 | 148 | goto placed_enemy; | |
| 19849 | } | ||
| 19850 | ✗ | } | |
| 19851 | 372567 | } | |
| 19852 | 23218 | } | |
| 19853 | |||
| 19854 | // Next: enemy pattern | ||
| 19855 |
6/8✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1966 times.
✓ Branch 2 taken 1966 times.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 1966 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1966 times.
|
2044 | if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) |
| 19856 | { | ||
| 19857 | 1966 | do | |
| 19858 | { | ||
| 19859 | |||
| 19860 | // NES positions | ||
| 19861 | 2914 | pos%=9; | |
| 19862 | 2914 | x=stx[loadside][pos]; | |
| 19863 | 2914 | y=sty[loadside][pos]; | |
| 19864 | 2914 | ++pos; | |
| 19865 | 2914 | ++t; | |
| 19866 |
2/2✓ Branch 0 taken 948 times.
✓ Branch 1 taken 1966 times.
|
4880 | } |
| 19867 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2913 times.
|
2914 | while((t< 20) && !is_starting_pos(i,x,y,t)); |
| 19868 | 1966 | } | |
| 19869 | |||
| 19870 |
4/4✓ Branch 0 taken 1966 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1965 times.
|
2044 | if(t<0 || t >= 20) // above enemy pattern failed |
| 19871 | { | ||
| 19872 | // Final chance: find a random position anywhere onscreen | ||
| 19873 | 79 | int32_t randpos = placeenemy(i); | |
| 19874 | |||
| 19875 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
|
79 | if(randpos>-1) |
| 19876 | { | ||
| 19877 | 79 | x=(randpos&15)<<4; | |
| 19878 | 79 | y= randpos&0xF0; | |
| 19879 | 79 | } | |
| 19880 | else // All opportunities failed - abort | ||
| 19881 | { | ||
| 19882 | ✗ | return; | |
| 19883 | } | ||
| 19884 | 79 | } | |
| 19885 | |||
| 19886 | { | ||
| 19887 | 2044 | int32_t c=0; | |
| 19888 | 2044 | c=clk; | |
| 19889 | |||
| 19890 |
2/2✓ Branch 0 taken 547 times.
✓ Branch 1 taken 1497 times.
|
2044 | if(!slowguy(tmpscr->enemy[i])) |
| 19891 | 1497 | ++fastguys; | |
| 19892 |
2/2✓ Branch 0 taken 35 times.
✓ Branch 1 taken 512 times.
|
547 | else if(fastguys>0) |
| 19893 | 35 | c=-15*(i-fastguys+2); | |
| 19894 | else | ||
| 19895 | 512 | c=-15*(i+1); | |
| 19896 | |||
| 19897 |
4/6✓ Branch 0 taken 333 times.
✓ Branch 1 taken 1711 times.
✓ Branch 2 taken 333 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 333 times.
|
2044 | if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1). |
| 19898 | { | ||
| 19899 | // Special case for blue leevers | ||
| 19900 |
4/4✓ Branch 0 taken 22 times.
✓ Branch 1 taken 311 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 16 times.
|
333 | if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1) |
| 19901 | 6 | c=-15*(i+1); | |
| 19902 | else | ||
| 19903 | 327 | c=-15; | |
| 19904 | 333 | } | |
| 19905 | |||
| 19906 |
2/2✓ Branch 0 taken 2016 times.
✓ Branch 1 taken 28 times.
|
2044 | if(!ok2add(tmpscr->enemy[i])) |
| 19907 | { | ||
| 19908 |
4/6✓ Branch 0 taken 2 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
28 | if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt; |
| 19909 | 28 | } | |
| 19910 | else | ||
| 19911 | { | ||
| 19912 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2016 | if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1). |
| 19913 | { | ||
| 19914 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4032 | addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y, |
| 19915 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 2016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
2016 | (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c); |
| 19916 | |||
| 19917 | 2016 | ++guycnt; | |
| 19918 | 2016 | } | |
| 19919 | } | ||
| 19920 | |||
| 19921 | 2044 | placed=true; | |
| 19922 | 2044 | } // if(t < 20) | |
| 19923 | |||
| 19924 | placed_enemy: | ||
| 19925 | |||
| 19926 | // I don't like this, but it seems to work... | ||
| 19927 | static bool foundCarrier; | ||
| 19928 | |||
| 19929 |
2/2✓ Branch 0 taken 1551 times.
✓ Branch 1 taken 641 times.
|
2192 | if(i==0) |
| 19930 | 641 | foundCarrier=false; | |
| 19931 | |||
| 19932 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2192 times.
|
2192 | if(placed) |
| 19933 | { | ||
| 19934 |
4/4✓ Branch 0 taken 641 times.
✓ Branch 1 taken 1551 times.
✓ Branch 2 taken 634 times.
✓ Branch 3 taken 7 times.
|
2192 | if(i==0 && tmpscr->enemyflags&efLEADER) |
| 19935 | { | ||
| 19936 | 7 | int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF); | |
| 19937 | |||
| 19938 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if(index!=-1) |
| 19939 | { | ||
| 19940 | //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor. | ||
| 19941 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7 | if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF); |
| 19942 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | if(index!=-1) |
| 19943 | { | ||
| 19944 | 7 | ((enemy*)guys.spr(index))->leader = true; | |
| 19945 | 7 | } | |
| 19946 | 7 | } | |
| 19947 | 7 | } | |
| 19948 | |||
| 19949 |
4/4✓ Branch 0 taken 2161 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 2153 times.
✓ Branch 3 taken 8 times.
|
2192 | if(!foundCarrier && hasitem&(4|2)) |
| 19950 | { | ||
| 19951 | 8 | int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF); | |
| 19952 | |||
| 19953 |
2/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
|
8 | if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0) |
| 19954 | { | ||
| 19955 | 8 | ((enemy*)guys.spr(index))->itemguy = true; | |
| 19956 | 8 | foundCarrier=true; | |
| 19957 | 8 | } | |
| 19958 | 8 | } | |
| 19959 | 2192 | } | |
| 19960 | 2192 | } | |
| 19961 | |||
| 19962 | ✗ | bool scriptloadenemies() | |
| 19963 | { | ||
| 19964 | ✗ | loaded_enemies = true; | |
| 19965 | ✗ | if(script_sle || sle_clk) return false; | |
| 19966 | ✗ | if(tmpscr->pattern==pNOSPAWN) return false; | |
| 19967 | |||
| 19968 | ✗ | if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR) | |
| 19969 | { | ||
| 19970 | ✗ | script_side_load_enemies(); | |
| 19971 | ✗ | return true; | |
| 19972 | } | ||
| 19973 | |||
| 19974 | ✗ | int32_t pos=zc_oldrand()%9; | |
| 19975 | ✗ | int32_t clk=-15,x=0,y=0,fastguys=0; | |
| 19976 | ✗ | int32_t i=0,guycnt=0; | |
| 19977 | ✗ | int32_t loadcnt = 10; | |
| 19978 | |||
| 19979 | ✗ | for(; i<loadcnt && tmpscr->enemy[i]>0; i++) | |
| 19980 | { | ||
| 19981 | ✗ | int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one. | |
| 19982 | ✗ | spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt); | |
| 19983 | ✗ | if (guys.Count() > preguycount) | |
| 19984 | { | ||
| 19985 | ✗ | if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME)) | |
| 19986 | { | ||
| 19987 | ✗ | if (!FFCore.system_suspend[susptNPCSCRIPTS]) | |
| 19988 | { | ||
| 19989 | ✗ | guys.spr(guys.Count()-1)->run_script(MODE_NORMAL); | |
| 19990 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true; | |
| 19991 | ✗ | } | |
| 19992 | ✗ | } | |
| 19993 | ✗ | } | |
| 19994 | ✗ | --clk; | |
| 19995 | ✗ | } | |
| 19996 | ✗ | return true; | |
| 19997 | ✗ | } | |
| 19998 | |||
| 19999 | 783209 | void loadenemies() | |
| 20000 | { | ||
| 20001 |
3/4✓ Branch 0 taken 783209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6547 times.
✓ Branch 3 taken 776662 times.
|
783209 | if(script_sle || sle_clk) |
| 20002 | { | ||
| 20003 | 6547 | side_load_enemies(); | |
| 20004 | 6547 | return; | |
| 20005 | } | ||
| 20006 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 776662 times.
|
776662 | if(tmpscr->pattern==pNOSPAWN) return; |
| 20007 |
2/2✓ Branch 0 taken 774972 times.
✓ Branch 1 taken 1690 times.
|
776662 | if(loaded_enemies) |
| 20008 | 774972 | return; | |
| 20009 | |||
| 20010 | // check if it's the dungeon boss and it has been beaten before | ||
| 20011 |
4/4✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1675 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 1 times.
|
1690 | if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS) |
| 20012 | { | ||
| 20013 | 1 | loaded_enemies = true; | |
| 20014 | 1 | return; | |
| 20015 | } | ||
| 20016 | |||
| 20017 |
4/4✓ Branch 0 taken 1624 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 1613 times.
|
1689 | if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR) |
| 20018 | { | ||
| 20019 | 76 | side_load_enemies(); | |
| 20020 | 76 | return; | |
| 20021 | } | ||
| 20022 | |||
| 20023 | 1613 | loaded_enemies=true; | |
| 20024 | |||
| 20025 | // do enemies that are always loaded | ||
| 20026 | 1613 | load_default_enemies(); | |
| 20027 | |||
| 20028 | // dungeon basements | ||
| 20029 | |||
| 20030 | static byte dngn_enemy_x[4] = {32,96,144,208}; | ||
| 20031 | |||
| 20032 |
2/2✓ Branch 0 taken 61 times.
✓ Branch 1 taken 1552 times.
|
1613 | if(currscr>=128) |
| 20033 | { | ||
| 20034 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 27 times.
|
61 | if(DMaps[currdmap].flags&dmfCAVES) return; |
| 20035 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
|
27 | if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES ) |
| 20036 | { | ||
| 20037 | ✗ | for(int32_t i=0; i<10; i++) | |
| 20038 | { | ||
| 20039 | ✗ | if ( tmpscr->enemy[i] ) | |
| 20040 | { | ||
| 20041 | ✗ | int32_t preguycount = guys.Count(); | |
| 20042 | ✗ | addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i); | |
| 20043 | ✗ | if (guys.Count() > preguycount) | |
| 20044 | { | ||
| 20045 | ✗ | if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME)) | |
| 20046 | { | ||
| 20047 | ✗ | if (!FFCore.system_suspend[susptNPCSCRIPTS]) | |
| 20048 | { | ||
| 20049 | ✗ | guys.spr(guys.Count()-1)->run_script(MODE_NORMAL); | |
| 20050 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true; | |
| 20051 | ✗ | } | |
| 20052 | ✗ | } | |
| 20053 | ✗ | } | |
| 20054 | ✗ | } | |
| 20055 | ✗ | } | |
| 20056 | ✗ | } | |
| 20057 | else | ||
| 20058 | { | ||
| 20059 |
2/2✓ Branch 0 taken 108 times.
✓ Branch 1 taken 27 times.
|
135 | for(int32_t i=0; i<4; i++) |
| 20060 | { | ||
| 20061 | 108 | int32_t preguycount = guys.Count(); | |
| 20062 |
2/2✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
|
108 | addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i); |
| 20063 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
|
108 | if (guys.Count() > preguycount) |
| 20064 | { | ||
| 20065 |
1/2✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
|
108 | if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME)) |
| 20066 | { | ||
| 20067 | ✗ | if (!FFCore.system_suspend[susptNPCSCRIPTS]) | |
| 20068 | { | ||
| 20069 | ✗ | guys.spr(guys.Count()-1)->run_script(MODE_NORMAL); | |
| 20070 | ✗ | ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true; | |
| 20071 | ✗ | } | |
| 20072 | ✗ | } | |
| 20073 | 108 | } | |
| 20074 | 108 | } | |
| 20075 | } | ||
| 20076 | 27 | return; | |
| 20077 | } | ||
| 20078 | |||
| 20079 | // check if it's been long enough to reload all enemies | ||
| 20080 | |||
| 20081 | 1552 | int32_t loadcnt = 10; | |
| 20082 | 1552 | int16_t s = (currmap<<7)+currscr; | |
| 20083 | 1552 | bool beenhere = false; | |
| 20084 | 1552 | bool reload = true; | |
| 20085 | 1552 | bool unbeatablereload = true; | |
| 20086 | |||
| 20087 |
2/2✓ Branch 0 taken 9312 times.
✓ Branch 1 taken 1552 times.
|
10864 | for(int32_t i=0; i<6; i++) |
| 20088 |
2/2✓ Branch 0 taken 8967 times.
✓ Branch 1 taken 345 times.
|
9657 | if(visited[i]==s) |
| 20089 | 345 | beenhere = true; | |
| 20090 | |||
| 20091 |
2/2✓ Branch 0 taken 345 times.
✓ Branch 1 taken 1207 times.
|
1552 | if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them. |
| 20092 | { | ||
| 20093 | 1207 | visited[vhead]=s; //If not, it adds it to the array, | |
| 20094 | 1207 | vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next. | |
| 20095 | 1207 | } | |
| 20096 |
2/2✓ Branch 0 taken 75 times.
✓ Branch 1 taken 270 times.
|
345 | else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0, |
| 20097 | { | ||
| 20098 | 270 | loadcnt = 0; //It will tell it not to load any enemies, | |
| 20099 | 270 | reload = false; //both by setting loadcnt to 0 and making the reload if statement not run. | |
| 20100 | 270 | } | |
| 20101 | |||
| 20102 |
2/2✓ Branch 0 taken 270 times.
✓ Branch 1 taken 1282 times.
|
1552 | if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive. |
| 20103 | { | ||
| 20104 | 1282 | loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive. | |
| 20105 | |||
| 20106 |
2/4✓ Branch 0 taken 243 times.
✓ Branch 1 taken 1039 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1282 | if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens. |
| 20107 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 243 times.
|
243 | (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens. |
| 20108 | 1039 | loadcnt = 10; //That means all enemies need to be respawned. | |
| 20109 |
3/4✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 1207 times.
✗ Branch 3 not taken.
|
1282 | if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD)) |
| 20110 | { | ||
| 20111 | ✗ | for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++) | |
| 20112 | { | ||
| 20113 | ✗ | if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount)) | |
| 20114 | { | ||
| 20115 | ✗ | unbeatablereload = false; | |
| 20116 | ✗ | } | |
| 20117 | ✗ | } | |
| 20118 | ✗ | if (unbeatablereload) | |
| 20119 | { | ||
| 20120 | ✗ | loadcnt = 10; | |
| 20121 | ✗ | } | |
| 20122 | ✗ | } | |
| 20123 | 1282 | } | |
| 20124 | |||
| 20125 |
4/4✓ Branch 0 taken 1538 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1536 times.
|
1552 | if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen, |
| 20126 | 16 | loadcnt = 10; //All enemies also need to be respawned. | |
| 20127 | |||
| 20128 | 1552 | int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly. | |
| 20129 | 1552 | int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof. | |
| 20130 | 1552 | int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy. | |
| 20131 | |||
| 20132 |
4/4✓ Branch 0 taken 512 times.
✓ Branch 1 taken 3232 times.
✓ Branch 2 taken 2192 times.
✓ Branch 3 taken 1552 times.
|
3744 | for(; i<loadcnt && tmpscr->enemy[i]>0; i++) |
| 20133 | { | ||
| 20134 | 2192 | int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one. | |
| 20135 | 2192 | spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt); | |
| 20136 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 2164 times.
|
2192 | if (guys.Count() > preguycount) |
| 20137 | { | ||
| 20138 |
2/2✓ Branch 0 taken 2123 times.
✓ Branch 1 taken 41 times.
|
2164 | if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME)) |
| 20139 | { | ||
| 20140 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
|
41 | if (!FFCore.system_suspend[susptNPCSCRIPTS]) |
| 20141 | { | ||
| 20142 | 41 | guys.spr(guys.Count()-1)->run_script(MODE_NORMAL); | |
| 20143 | 41 | ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true; | |
| 20144 | 41 | } | |
| 20145 | 41 | } | |
| 20146 | 2164 | } | |
| 20147 | |||
| 20148 | 2192 | --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous. | |
| 20149 | 2192 | } | |
| 20150 | |||
| 20151 | 1552 | game->guys[s] = guycnt; | |
| 20152 | //} //if(true) | ||
| 20153 | 783209 | } | |
| 20154 | 7 | void moneysign() | |
| 20155 | { | ||
| 20156 | 7 | additem(48,108,iRupy,ipDUMMY); | |
| 20157 | 7 | set_clip_state(pricesdisplaybuf, 0); | |
| 20158 | 7 | textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1); | |
| 20159 | 7 | } | |
| 20160 | |||
| 20161 | 99 | void putprices(bool sign) | |
| 20162 | { | ||
| 20163 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
|
99 | if(fadeclk > 0) return; |
| 20164 | |||
| 20165 | 99 | rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0); | |
| 20166 | 99 | int32_t step=32; | |
| 20167 | 99 | int32_t x=80; | |
| 20168 | |||
| 20169 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 94 times.
|
99 | if(prices[2]==0) |
| 20170 | { | ||
| 20171 | 94 | step<<=1; | |
| 20172 | |||
| 20173 |
2/2✓ Branch 0 taken 92 times.
✓ Branch 1 taken 2 times.
|
94 | if(prices[1]==0) |
| 20174 | { | ||
| 20175 | 92 | x=112; | |
| 20176 | 92 | } | |
| 20177 | 94 | } | |
| 20178 | |||
| 20179 |
2/2✓ Branch 0 taken 99 times.
✓ Branch 1 taken 297 times.
|
396 | for(int32_t i=0; i<3; i++) |
| 20180 | { | ||
| 20181 | // Kind of stupid, but it works: 100000 is used to indicate that an item | ||
| 20182 | // has a price of zero rather than there being no item. | ||
| 20183 | // 100000 isn't a valid price, so this doesn't cause problems. | ||
| 20184 |
3/4✓ Branch 0 taken 22 times.
✓ Branch 1 taken 275 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
|
297 | if(prices[i]!=0 && prices[i]<100000) |
| 20185 | { | ||
| 20186 | char buf[8]; | ||
| 20187 | 22 | sprintf(buf,sign?"%+3d":"%3d",prices[i]); | |
| 20188 | |||
| 20189 | 22 | int32_t l=(int32_t)strlen(buf); | |
| 20190 | 22 | set_clip_state(pricesdisplaybuf, 0); | |
| 20191 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
|
22 | textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1); |
| 20192 | 22 | } | |
| 20193 | |||
| 20194 | 297 | x+=step; | |
| 20195 | 297 | } | |
| 20196 | 99 | } | |
| 20197 | |||
| 20198 | // Setting up special rooms | ||
| 20199 | // Also called when the Letter is used successfully. | ||
| 20200 | 67 | void setupscreen() | |
| 20201 | { | ||
| 20202 | 67 | boughtsomething=false; | |
| 20203 | 67 | int32_t t=currscr<128?0:1; | |
| 20204 | 67 | word str=tmpscr[t].str; | |
| 20205 | |||
| 20206 | // Prices are already set to 0 in dowarp() | ||
| 20207 |
6/15✓ Branch 0 taken 5 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
67 | switch(tmpscr[t].room) |
| 20208 | { | ||
| 20209 | case rSP_ITEM: // special item | ||
| 20210 | 22 | additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0)); | |
| 20211 | 22 | break; | |
| 20212 | |||
| 20213 | case rINFO: // pay for info | ||
| 20214 | { | ||
| 20215 | ✗ | int32_t count = 0; | |
| 20216 | ✗ | int32_t base = 88; | |
| 20217 | ✗ | int32_t step = 5; | |
| 20218 | |||
| 20219 | ✗ | moneysign(); | |
| 20220 | |||
| 20221 | ✗ | for(int32_t i=0; i<3; i++) | |
| 20222 | { | ||
| 20223 | ✗ | if(QMisc.info[tmpscr[t].catchall].str[i]) | |
| 20224 | { | ||
| 20225 | ✗ | ++count; | |
| 20226 | ✗ | } | |
| 20227 | else | ||
| 20228 | ✗ | break; | |
| 20229 | ✗ | } | |
| 20230 | |||
| 20231 | ✗ | if(count) | |
| 20232 | { | ||
| 20233 | ✗ | if(count==1) | |
| 20234 | { | ||
| 20235 | ✗ | base = 88+32; | |
| 20236 | ✗ | } | |
| 20237 | |||
| 20238 | ✗ | if(count==2) | |
| 20239 | { | ||
| 20240 | ✗ | step = 6; | |
| 20241 | ✗ | } | |
| 20242 | |||
| 20243 | ✗ | for(int32_t i=0; i < count; i++) | |
| 20244 | { | ||
| 20245 | ✗ | additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY); | |
| 20246 | ✗ | ((item*)items.spr(items.Count()-1))->PriceIndex = i; | |
| 20247 | ✗ | prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]); | |
| 20248 | ✗ | if(prices[i]==0) | |
| 20249 | ✗ | prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly | |
| 20250 | ✗ | int32_t itemid = current_item_id(itype_wealthmedal); | |
| 20251 | |||
| 20252 | ✗ | if(itemid>=0 && prices[i]!=100000) | |
| 20253 | { | ||
| 20254 | ✗ | if(itemsbuf[itemid].flags & ITEM_FLAG1) | |
| 20255 | ✗ | prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100); | |
| 20256 | else | ||
| 20257 | ✗ | prices[i]-=itemsbuf[itemid].misc1; | |
| 20258 | ✗ | prices[i]=vbound(prices[i], -99999, 0); | |
| 20259 | ✗ | if(prices[i]==0) | |
| 20260 | ✗ | prices[i]=100000; | |
| 20261 | ✗ | } | |
| 20262 | |||
| 20263 | ✗ | if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000) | |
| 20264 | ✗ | prices[i]=-1; | |
| 20265 | ✗ | } | |
| 20266 | ✗ | } | |
| 20267 | |||
| 20268 | ✗ | break; | |
| 20269 | } | ||
| 20270 | |||
| 20271 | case rMONEY: // secret money | ||
| 20272 | 3 | additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY); | |
| 20273 | 3 | ((item*)items.spr(items.Count()-1))->PriceIndex = 0; | |
| 20274 | 3 | break; | |
| 20275 | |||
| 20276 | case rGAMBLE: // gambling | ||
| 20277 | ✗ | prices[0]=prices[1]=prices[2]=-10; | |
| 20278 | ✗ | moneysign(); | |
| 20279 | ✗ | additem(88,89,iRupy,ipMONEY+ipDUMMY); | |
| 20280 | ✗ | ((item*)items.spr(items.Count()-1))->PriceIndex = 0; | |
| 20281 | ✗ | additem(120,89,iRupy,ipMONEY+ipDUMMY); | |
| 20282 | ✗ | ((item*)items.spr(items.Count()-1))->PriceIndex = 1; | |
| 20283 | ✗ | additem(152,89,iRupy,ipMONEY+ipDUMMY); | |
| 20284 | ✗ | ((item*)items.spr(items.Count()-1))->PriceIndex = 2; | |
| 20285 | ✗ | break; | |
| 20286 | |||
| 20287 | case rREPAIR: // door repair | ||
| 20288 | ✗ | setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM); | |
| 20289 | // } | ||
| 20290 | ✗ | repaircharge=tmpscr[t].catchall; | |
| 20291 | ✗ | break; | |
| 20292 | |||
| 20293 | case rMUPGRADE: // upgrade magic | ||
| 20294 | ✗ | adjustmagic=true; | |
| 20295 | ✗ | break; | |
| 20296 | |||
| 20297 | case rLEARNSLASH: // learn slash attack | ||
| 20298 | ✗ | learnslash=true; | |
| 20299 | ✗ | break; | |
| 20300 | |||
| 20301 | case rRP_HC: // heart container or red potion | ||
| 20302 | 4 | additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE); | |
| 20303 | 4 | ((item*)items.spr(items.Count()-1))->PriceIndex = 0; | |
| 20304 | 4 | additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE); | |
| 20305 | 4 | ((item*)items.spr(items.Count()-1))->PriceIndex = 1; | |
| 20306 | 4 | break; | |
| 20307 | |||
| 20308 | case rP_SHOP: // potion shop | ||
| 20309 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if(current_item(itype_letter)<i_letter_used) |
| 20310 | { | ||
| 20311 | ✗ | str=0; | |
| 20312 | ✗ | break; | |
| 20313 | } | ||
| 20314 | |||
| 20315 | [[fallthrough]]; | ||
| 20316 | case rTAKEONE: // take one | ||
| 20317 | case rSHOP: // shop | ||
| 20318 | { | ||
| 20319 | 7 | int32_t count = 0; | |
| 20320 | 7 | int32_t base = 88; | |
| 20321 | 7 | int32_t step = 5; | |
| 20322 | |||
| 20323 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | if(tmpscr[t].room != rTAKEONE) |
| 20324 | 7 | moneysign(); | |
| 20325 | |||
| 20326 | //count and align the stuff | ||
| 20327 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 21 times.
|
26 | for(int32_t i=0; i<3; ++i) |
| 20328 | { | ||
| 20329 |
2/2✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2 times.
|
21 | if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0) |
| 20330 | { | ||
| 20331 | 19 | ++count; | |
| 20332 | 19 | } | |
| 20333 | else | ||
| 20334 | { | ||
| 20335 | 2 | break; | |
| 20336 | } | ||
| 20337 | 19 | } | |
| 20338 | |||
| 20339 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if(count==1) |
| 20340 | { | ||
| 20341 | ✗ | base = 88+32; | |
| 20342 | ✗ | } | |
| 20343 | |||
| 20344 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
|
7 | if(count==2) |
| 20345 | { | ||
| 20346 | 2 | step = 6; | |
| 20347 | 2 | } | |
| 20348 | |||
| 20349 |
2/2✓ Branch 0 taken 19 times.
✓ Branch 1 taken 7 times.
|
26 | for(int32_t i=0; i<count; i++) |
| 20350 | { | ||
| 20351 | 19 | additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK)); | |
| 20352 | 19 | ((item*)items.spr(items.Count()-1))->PriceIndex = i; | |
| 20353 | |||
| 20354 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
|
19 | if(tmpscr[t].room != rTAKEONE) |
| 20355 | { | ||
| 20356 | 19 | prices[i] = QMisc.shop[tmpscr[t].catchall].price[i]; | |
| 20357 |
1/2✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
|
19 | if(prices[i]==0) |
| 20358 | ✗ | prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly | |
| 20359 | 19 | int32_t itemid = current_item_id(itype_wealthmedal); | |
| 20360 | |||
| 20361 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
19 | if(itemid>=0 && prices[i]!=100000) |
| 20362 | { | ||
| 20363 | ✗ | if(itemsbuf[itemid].flags & ITEM_FLAG1) | |
| 20364 | ✗ | prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100); | |
| 20365 | else | ||
| 20366 | ✗ | prices[i]+=itemsbuf[itemid].misc1; | |
| 20367 | ✗ | prices[i]=vbound(prices[i], 0, 99999); | |
| 20368 | ✗ | if(prices[i]==0) | |
| 20369 | ✗ | prices[i]=100000; | |
| 20370 | ✗ | } | |
| 20371 | |||
| 20372 |
2/4✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
|
19 | if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1) |
| 20373 | ✗ | prices[i]=1; | |
| 20374 | 19 | } | |
| 20375 | 19 | } | |
| 20376 | |||
| 20377 | 7 | break; | |
| 20378 | } | ||
| 20379 | case rBOTTLESHOP: // bottle shop | ||
| 20380 | { | ||
| 20381 | ✗ | int32_t count = 0; | |
| 20382 | ✗ | int32_t base = 88; | |
| 20383 | ✗ | int32_t step = 5; | |
| 20384 | |||
| 20385 | ✗ | moneysign(); | |
| 20386 | ✗ | bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall]; | |
| 20387 | //count and align the stuff | ||
| 20388 | ✗ | for(int32_t i=0; i<3; ++i) | |
| 20389 | { | ||
| 20390 | ✗ | if(bst.fill[count] != 0) | |
| 20391 | { | ||
| 20392 | ✗ | ++count; | |
| 20393 | ✗ | } | |
| 20394 | else | ||
| 20395 | { | ||
| 20396 | ✗ | break; | |
| 20397 | } | ||
| 20398 | ✗ | } | |
| 20399 | |||
| 20400 | ✗ | if(count==1) | |
| 20401 | { | ||
| 20402 | ✗ | base = 88+32; | |
| 20403 | ✗ | } | |
| 20404 | |||
| 20405 | ✗ | if(count==2) | |
| 20406 | { | ||
| 20407 | ✗ | step = 6; | |
| 20408 | ✗ | } | |
| 20409 | |||
| 20410 | ✗ | for(int32_t i=0; i<count; i++) | |
| 20411 | { | ||
| 20412 | ✗ | adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK); | |
| 20413 | //{ Setup dummy item | ||
| 20414 | ✗ | item* curItem = ((item*)items.spr(items.Count()-1)); | |
| 20415 | ✗ | curItem->PriceIndex = i; | |
| 20416 | ✗ | newcombo const& cmb = combobuf[bst.comb[i]]; | |
| 20417 | ✗ | curItem->o_tile = cmb.o_tile; | |
| 20418 | ✗ | curItem->o_cset = bst.cset[i]; | |
| 20419 | ✗ | curItem->cs = curItem->o_cset; | |
| 20420 | ✗ | curItem->tile = cmb.o_tile; | |
| 20421 | ✗ | curItem->o_speed = cmb.speed; | |
| 20422 | ✗ | curItem->o_delay = 0; | |
| 20423 | ✗ | curItem->frames = cmb.frames; | |
| 20424 | ✗ | curItem->flip = cmb.flip; | |
| 20425 | ✗ | curItem->family = itype_bottlefill; //no pickup w/o empty bottle | |
| 20426 | ✗ | curItem->pstring = 0; | |
| 20427 | ✗ | curItem->pickup = ipHOLDUP+ipFADE+ipCHECK; | |
| 20428 | ✗ | curItem->flash = false; | |
| 20429 | ✗ | curItem->twohand = false; | |
| 20430 | ✗ | curItem->anim = true; | |
| 20431 | ✗ | curItem->hit_width=1; | |
| 20432 | ✗ | curItem->hyofs=4; | |
| 20433 | ✗ | curItem->hit_height=12; | |
| 20434 | ✗ | curItem->script=0; | |
| 20435 | ✗ | curItem->txsz=1; | |
| 20436 | ✗ | curItem->tysz=1; | |
| 20437 | //} | ||
| 20438 | |||
| 20439 | ✗ | prices[i] = bst.price[i]; | |
| 20440 | ✗ | if(prices[i]==0) | |
| 20441 | ✗ | prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly | |
| 20442 | ✗ | int32_t itemid = current_item_id(itype_wealthmedal); | |
| 20443 | |||
| 20444 | ✗ | if(itemid>=0 && prices[i]!=100000) | |
| 20445 | { | ||
| 20446 | ✗ | if(itemsbuf[itemid].flags & ITEM_FLAG1) | |
| 20447 | ✗ | prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100); | |
| 20448 | else | ||
| 20449 | ✗ | prices[i]+=itemsbuf[itemid].misc1; | |
| 20450 | ✗ | prices[i]=vbound(prices[i], 0, 99999); | |
| 20451 | ✗ | if(prices[i]==0) | |
| 20452 | ✗ | prices[i]=100000; | |
| 20453 | ✗ | } | |
| 20454 | |||
| 20455 | ✗ | if((bst.price[i])>1 && prices[i]<1) | |
| 20456 | ✗ | prices[i]=1; | |
| 20457 | ✗ | } | |
| 20458 | |||
| 20459 | ✗ | break; | |
| 20460 | } | ||
| 20461 | |||
| 20462 | case rBOMBS: // more bombs | ||
| 20463 | ✗ | additem(120,89,iRupy,ipDUMMY+ipMONEY); | |
| 20464 | ✗ | ((item*)items.spr(items.Count()-1))->PriceIndex = 0; | |
| 20465 | ✗ | prices[0]=-tmpscr[t].catchall; | |
| 20466 | ✗ | break; | |
| 20467 | |||
| 20468 | case rARROWS: // more arrows | ||
| 20469 | ✗ | additem(120,89,iRupy,ipDUMMY+ipMONEY); | |
| 20470 | ✗ | ((item*)items.spr(items.Count()-1))->PriceIndex = 0; | |
| 20471 | ✗ | prices[0]=-tmpscr[t].catchall; | |
| 20472 | ✗ | break; | |
| 20473 | |||
| 20474 | case rSWINDLE: // leave heart container or money | ||
| 20475 | ✗ | additem(88,89,iHeartC,ipDUMMY+ipMONEY); | |
| 20476 | ✗ | ((item*)items.spr(items.Count()-1))->PriceIndex = 0; | |
| 20477 | ✗ | prices[0]=-1; | |
| 20478 | ✗ | additem(152,89,iRupy,ipDUMMY+ipMONEY); | |
| 20479 | ✗ | ((item*)items.spr(items.Count()-1))->PriceIndex = 1; | |
| 20480 | ✗ | prices[1]=-tmpscr[t].catchall; | |
| 20481 | ✗ | break; | |
| 20482 | |||
| 20483 | } | ||
| 20484 | |||
| 20485 |
2/4✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
|
67 | if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS) |
| 20486 | { | ||
| 20487 | ✗ | int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0); | |
| 20488 | ✗ | int32_t itemid = current_item_id(itype_wealthmedal); | |
| 20489 | |||
| 20490 | ✗ | if(itemid >= 0) | |
| 20491 | { | ||
| 20492 | ✗ | if(itemsbuf[itemid].flags & ITEM_FLAG1) | |
| 20493 | ✗ | prices[i]*=(itemsbuf[itemid].misc1/100.0); | |
| 20494 | else | ||
| 20495 | ✗ | prices[i]+=itemsbuf[itemid].misc1; | |
| 20496 | ✗ | } | |
| 20497 | |||
| 20498 | ✗ | if(tmpscr[t].catchall>1 && prices[i]>-1) | |
| 20499 | ✗ | prices[i]=-1; | |
| 20500 | ✗ | } | |
| 20501 | |||
| 20502 | 67 | putprices(false); | |
| 20503 | |||
| 20504 |
2/2✓ Branch 0 taken 64 times.
✓ Branch 1 taken 3 times.
|
67 | if(str) |
| 20505 | { | ||
| 20506 | 64 | donewmsg(str); | |
| 20507 | 64 | } | |
| 20508 | else | ||
| 20509 | { | ||
| 20510 | 3 | Hero.unfreeze(); | |
| 20511 | } | ||
| 20512 | 67 | } | |
| 20513 | |||
| 20514 | // Increments msgptr and returns the control code argument pointed at. | ||
| 20515 | 18 | word grab_next_argument() | |
| 20516 | { | ||
| 20517 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0; |
| 20518 | 18 | byte val=MsgStrings[msgstr].s[++msgptr]-1; | |
| 20519 | 18 | word ret=val; | |
| 20520 | |||
| 20521 | // If an argument is succeeded by 255, then it's a three-byte argument - | ||
| 20522 | // between 254 and 65535 (or whatever the maximum actually is) | ||
| 20523 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size()) |
| 20524 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255) |
| 20525 | { | ||
| 20526 | ✗ | val=MsgStrings[msgstr].s[msgptr+2]; | |
| 20527 | ✗ | word next=val; | |
| 20528 | ✗ | ret += 254*next; | |
| 20529 | ✗ | msgptr+=2; | |
| 20530 | ✗ | } | |
| 20531 | |||
| 20532 | 18 | return ret; | |
| 20533 | 18 | } | |
| 20534 | |||
| 20535 | enum | ||
| 20536 | { | ||
| 20537 | MNU_CURSOR_TILE, MNU_CURSOR_CSET, | ||
| 20538 | MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP, | ||
| 20539 | |||
| 20540 | MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM, | ||
| 20541 | |||
| 20542 | MNU_DATA_MAX | ||
| 20543 | }; | ||
| 20544 | struct menu_choice | ||
| 20545 | { | ||
| 20546 | int32_t x, y; | ||
| 20547 | int32_t pos; | ||
| 20548 | int32_t upos, dpos, lpos, rpos; | ||
| 20549 | ✗ | menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0) | |
| 20550 | ✗ | {} | |
| 20551 | ✗ | menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos, | |
| 20552 | int32_t dpos, int32_t lpos, int32_t rpos) | ||
| 20553 | ✗ | : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos) | |
| 20554 | ✗ | {} | |
| 20555 | }; | ||
| 20556 | static int32_t msg_menu_data[MNU_DATA_MAX]; | ||
| 20557 | static bool do_run_menu = false; | ||
| 20558 | bool do_end_str = false; | ||
| 20559 | static bool wait_advance = false; | ||
| 20560 | 350 | static std::map<int32_t, menu_choice> menu_options; | |
| 20561 | 2039 | void clr_msg_data() | |
| 20562 | { | ||
| 20563 | 2039 | do_end_str = false; | |
| 20564 | 2039 | wait_advance = false; | |
| 20565 | 2039 | do_run_menu = false; | |
| 20566 | 2039 | menu_options.clear(); | |
| 20567 | 2039 | memset(msg_menu_data, 0, sizeof(msg_menu_data)); | |
| 20568 | 2039 | } | |
| 20569 | |||
| 20570 | static bool doing_name_insert = false; | ||
| 20571 | static char namebuf[9] = {0}; | ||
| 20572 | static char* nameptr = NULL; | ||
| 20573 | static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1; | ||
| 20574 | ✗ | bool runMenuCursor() | |
| 20575 | { | ||
| 20576 | ✗ | clear_bitmap(msg_menu_bmp_buf); | |
| 20577 | ✗ | if(!menu_options.size()) | |
| 20578 | { | ||
| 20579 | ✗ | msg_menu_data[MNU_CHOSEN] = 0; | |
| 20580 | ✗ | return true; //end menu | |
| 20581 | } | ||
| 20582 | ✗ | int32_t pos = msg_menu_data[MNU_CHOSEN]; | |
| 20583 | //If the cursor is at an invalid pos, find the first pos >= 0... | ||
| 20584 | ✗ | if(menu_options.find(pos) == menu_options.end()) | |
| 20585 | { | ||
| 20586 | ✗ | pos = 0; | |
| 20587 | ✗ | while(menu_options.find(pos) == menu_options.end()) | |
| 20588 | ✗ | ++pos; | |
| 20589 | ✗ | } | |
| 20590 | ✗ | menu_choice* ch = &menu_options[pos]; | |
| 20591 | |||
| 20592 | ✗ | bool pressed = true; | |
| 20593 | ✗ | if(rUp()) pos = ch->upos; | |
| 20594 | ✗ | else if(rDown()) pos = ch->dpos; | |
| 20595 | ✗ | else if(rLeft()) pos = ch->lpos; | |
| 20596 | ✗ | else if(rRight()) pos = ch->rpos; | |
| 20597 | ✗ | else pressed = false; | |
| 20598 | |||
| 20599 | ✗ | if(pressed) | |
| 20600 | ✗ | msg_menu_data[MNU_TIMER] = 1; | |
| 20601 | |||
| 20602 | ✗ | bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20); | |
| 20603 | ✗ | bool held = false; | |
| 20604 | ✗ | if(hold_input) | |
| 20605 | { | ||
| 20606 | ✗ | held = true; | |
| 20607 | ✗ | if(Up()) pos = ch->upos; | |
| 20608 | ✗ | else if(Down()) pos = ch->dpos; | |
| 20609 | ✗ | else if(Left()) pos = ch->lpos; | |
| 20610 | ✗ | else if(Right()) pos = ch->rpos; | |
| 20611 | ✗ | else held = false; | |
| 20612 | ✗ | } | |
| 20613 | //If the cursor is at an invalid pos, find the first pos >= 0... | ||
| 20614 | ✗ | if(menu_options.find(pos) == menu_options.end()) | |
| 20615 | { | ||
| 20616 | ✗ | pos = 0; | |
| 20617 | ✗ | while(menu_options.find(pos) == menu_options.end()) | |
| 20618 | ✗ | ++pos; | |
| 20619 | ✗ | } | |
| 20620 | ✗ | if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN]) | |
| 20621 | ✗ | sfx(MsgStrings[msgstr].sfx); | |
| 20622 | |||
| 20623 | ✗ | ch = &menu_options[pos]; | |
| 20624 | ✗ | overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE], | |
| 20625 | ✗ | ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0), | |
| 20626 | ✗ | (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0), | |
| 20627 | ✗ | msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]); | |
| 20628 | |||
| 20629 | ✗ | msg_menu_data[MNU_CHOSEN] = pos; | |
| 20630 | |||
| 20631 | ✗ | if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A | |
| 20632 | { | ||
| 20633 | ✗ | rAbtn(); //Eat | |
| 20634 | ✗ | if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1; | |
| 20635 | ✗ | } | |
| 20636 | |||
| 20637 | ✗ | bool ret = (pressed || held) ? false : rAbtn(); | |
| 20638 | //Eat inputs | ||
| 20639 | ✗ | rUp(); rDown(); rLeft(); rRight(); rAbtn(); | |
| 20640 | |||
| 20641 | ✗ | if(ret) | |
| 20642 | ✗ | menu_options.clear(); | |
| 20643 | |||
| 20644 | ✗ | return ret; | |
| 20645 | //false if pos changed this frame; no confirming while moving the cursor! | ||
| 20646 | ✗ | } | |
| 20647 | |||
| 20648 | 25615 | bool bottom_margin_clip() | |
| 20649 | { | ||
| 20650 | 25915 | return !get_qr(qr_OLD_STRING_EDITOR_MARGINS) | |
| 20651 |
2/2✓ Branch 0 taken 25315 times.
✓ Branch 1 taken 300 times.
|
25615 | && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]); |
| 20652 | } | ||
| 20653 | |||
| 20654 | void update_msgstr(); | ||
| 20655 | 6341 | bool parsemsgcode() | |
| 20656 | { | ||
| 20657 |
2/2✓ Branch 0 taken 127 times.
✓ Branch 1 taken 6214 times.
|
6341 | if(msgptr>=MsgStrings[msgstr].s.size()) return false; |
| 20658 | 6214 | byte c = byte(MsgStrings[msgstr].s[msgptr]-1); | |
| 20659 |
3/39✗ Branch 0 not taken.
✓ Branch 1 taken 6197 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
|
6214 | switch(c) |
| 20660 | { | ||
| 20661 | case MSGC_NEWLINE: | ||
| 20662 | { | ||
| 20663 | 8 | ssc_tile_hei = ssc_tile_hei_buf; | |
| 20664 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); |
| 20665 | 8 | ssc_tile_hei_buf = -1; | |
| 20666 | 8 | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 20667 | 8 | cursor_x=msg_margins[left]; | |
| 20668 | 8 | return true; | |
| 20669 | } | ||
| 20670 | |||
| 20671 | case MSGC_COLOUR: | ||
| 20672 | { | ||
| 20673 | 9 | int32_t cset = (grab_next_argument()); | |
| 20674 | 9 | msgcolour = CSET(cset)+(grab_next_argument()); | |
| 20675 | 9 | return true; | |
| 20676 | } | ||
| 20677 | |||
| 20678 | case MSGC_SHDCOLOR: | ||
| 20679 | { | ||
| 20680 | ✗ | int32_t cset = (grab_next_argument()); | |
| 20681 | ✗ | msg_shdcol = CSET(cset)+(grab_next_argument()); | |
| 20682 | ✗ | return true; | |
| 20683 | } | ||
| 20684 | case MSGC_SHDTYPE: | ||
| 20685 | { | ||
| 20686 | ✗ | msg_shdtype = grab_next_argument(); | |
| 20687 | ✗ | return true; | |
| 20688 | } | ||
| 20689 | |||
| 20690 | case MSGC_SPEED: | ||
| 20691 | { | ||
| 20692 | ✗ | msgspeed=grab_next_argument(); | |
| 20693 | ✗ | return true; | |
| 20694 | } | ||
| 20695 | |||
| 20696 | case MSGC_CTRUP: | ||
| 20697 | { | ||
| 20698 | ✗ | int32_t a1 = grab_next_argument(); | |
| 20699 | ✗ | int32_t a2 = grab_next_argument(); | |
| 20700 | ✗ | game->change_counter(a2, a1); | |
| 20701 | ✗ | return true; | |
| 20702 | } | ||
| 20703 | |||
| 20704 | case MSGC_CTRDN: | ||
| 20705 | { | ||
| 20706 | ✗ | int32_t a1 = grab_next_argument(); | |
| 20707 | ✗ | int32_t a2 = grab_next_argument(); | |
| 20708 | ✗ | game->change_counter(-a2, a1); | |
| 20709 | ✗ | return true; | |
| 20710 | } | ||
| 20711 | |||
| 20712 | case MSGC_CTRSET: | ||
| 20713 | { | ||
| 20714 | ✗ | int32_t a1 = grab_next_argument(); | |
| 20715 | ✗ | int32_t a2 = grab_next_argument(); | |
| 20716 | ✗ | game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1); | |
| 20717 | ✗ | return true; | |
| 20718 | } | ||
| 20719 | |||
| 20720 | case MSGC_CTRUPPC: | ||
| 20721 | case MSGC_CTRDNPC: | ||
| 20722 | case MSGC_CTRSETPC: | ||
| 20723 | { | ||
| 20724 | ✗ | int32_t code = MsgStrings[msgstr].s[msgptr]-1; | |
| 20725 | ✗ | int32_t counter = grab_next_argument(); | |
| 20726 | ✗ | int32_t amount = grab_next_argument(); | |
| 20727 | ✗ | amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter)); | |
| 20728 | |||
| 20729 | ✗ | if(code==MSGC_CTRDNPC) | |
| 20730 | ✗ | amount*=-1; | |
| 20731 | |||
| 20732 | ✗ | if(code==MSGC_CTRSETPC) | |
| 20733 | ✗ | game->set_counter(amount, counter); | |
| 20734 | else | ||
| 20735 | ✗ | game->change_counter(amount, counter); | |
| 20736 | |||
| 20737 | ✗ | return true; | |
| 20738 | } | ||
| 20739 | |||
| 20740 | case MSGC_GIVEITEM: | ||
| 20741 | { | ||
| 20742 | ✗ | int32_t itemID = grab_next_argument(); | |
| 20743 | |||
| 20744 | ✗ | getitem(itemID, true); | |
| 20745 | ✗ | if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) ) | |
| 20746 | { | ||
| 20747 | ✗ | FFCore.reset_script_engine_data(ScriptType::Item, itemID); | |
| 20748 | ✗ | FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) > 0; | |
| 20749 | ✗ | } | |
| 20750 | ✗ | return true; | |
| 20751 | } | ||
| 20752 | |||
| 20753 | |||
| 20754 | case MSGC_WARP: | ||
| 20755 | { | ||
| 20756 | ✗ | int32_t dmap = grab_next_argument(); | |
| 20757 | ✗ | int32_t scrn = grab_next_argument(); | |
| 20758 | ✗ | int32_t dx = grab_next_argument(); | |
| 20759 | ✗ | int32_t dy = grab_next_argument(); | |
| 20760 | ✗ | int32_t wfx = grab_next_argument(); | |
| 20761 | ✗ | int32_t sfx = grab_next_argument(); | |
| 20762 | ✗ | if(dx >= MAX_SCC_ARG) dx = -1; | |
| 20763 | ✗ | if(dy >= MAX_SCC_ARG) dy = -1; | |
| 20764 | ✗ | FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0); | |
| 20765 | ✗ | do_end_str = true; | |
| 20766 | ✗ | return true; | |
| 20767 | } | ||
| 20768 | |||
| 20769 | case MSGC_SETSCREEND: | ||
| 20770 | { | ||
| 20771 | ✗ | int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here. | |
| 20772 | ✗ | int32_t screen = grab_next_argument(); | |
| 20773 | ✗ | int32_t reg = grab_next_argument(); | |
| 20774 | ✗ | int32_t val = grab_next_argument(); | |
| 20775 | ✗ | FFCore.set_screen_d(screen + dmap, reg, val); | |
| 20776 | ✗ | return true; | |
| 20777 | } | ||
| 20778 | case MSGC_TAKEITEM: | ||
| 20779 | { | ||
| 20780 | ✗ | int32_t itemID = grab_next_argument(); | |
| 20781 | ✗ | if ( FFCore.doscript(ScriptType::Item, itemID) ) | |
| 20782 | { | ||
| 20783 | ✗ | FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit' | |
| 20784 | ✗ | } | |
| 20785 | ✗ | takeitem(itemID); | |
| 20786 | ✗ | if ( game->forced_bwpn == itemID ) | |
| 20787 | { | ||
| 20788 | ✗ | game->forced_bwpn = -1; | |
| 20789 | ✗ | } //not else if! -Z | |
| 20790 | ✗ | if ( game->forced_awpn == itemID ) | |
| 20791 | { | ||
| 20792 | ✗ | game->forced_awpn = -1; | |
| 20793 | ✗ | } | |
| 20794 | ✗ | if ( game->forced_xwpn == itemID ) | |
| 20795 | { | ||
| 20796 | ✗ | game->forced_xwpn = -1; | |
| 20797 | ✗ | } //not else if! -Z | |
| 20798 | ✗ | if ( game->forced_ywpn == itemID ) | |
| 20799 | { | ||
| 20800 | ✗ | game->forced_ywpn = -1; | |
| 20801 | ✗ | } | |
| 20802 | ✗ | verifyBothWeapons(); | |
| 20803 | ✗ | return true; | |
| 20804 | } | ||
| 20805 | |||
| 20806 | case MSGC_SFX: | ||
| 20807 | { | ||
| 20808 | ✗ | sfx((int32_t)grab_next_argument(),128); | |
| 20809 | ✗ | return true; | |
| 20810 | } | ||
| 20811 | |||
| 20812 | case MSGC_MIDI: | ||
| 20813 | { | ||
| 20814 | ✗ | int32_t music = (int32_t)(grab_next_argument()); | |
| 20815 | |||
| 20816 | ✗ | if(music==0) | |
| 20817 | ✗ | music_stop(); | |
| 20818 | else | ||
| 20819 | ✗ | jukebox(music+(ZC_MIDI_COUNT-1)); | |
| 20820 | |||
| 20821 | ✗ | return true; | |
| 20822 | } | ||
| 20823 | |||
| 20824 | case MSGC_NAME: | ||
| 20825 | { | ||
| 20826 | ✗ | doing_name_insert = true; | |
| 20827 | ✗ | sprintf(namebuf, "%s", game->get_name()); | |
| 20828 | ✗ | nameptr = namebuf; | |
| 20829 | ✗ | return true; | |
| 20830 | } | ||
| 20831 | |||
| 20832 | case MSGC_FONT: | ||
| 20833 | { | ||
| 20834 | ✗ | int fontid = grab_next_argument(); | |
| 20835 | ✗ | int oh = text_height(msgfont); | |
| 20836 | ✗ | msgfont = get_zc_font(fontid); | |
| 20837 | ✗ | int nh = text_height(msgfont); | |
| 20838 | ✗ | int mh = std::max(oh,nh); | |
| 20839 | ✗ | if(mh > ssc_tile_hei_buf) | |
| 20840 | ✗ | ssc_tile_hei_buf = mh; | |
| 20841 | ✗ | return true; | |
| 20842 | } | ||
| 20843 | case MSGC_RUN_FRZ_GENSCR: | ||
| 20844 | { | ||
| 20845 | ✗ | word scr_id = grab_next_argument(); | |
| 20846 | ✗ | bool force_redraw = grab_next_argument()!=0; | |
| 20847 | ✗ | if(force_redraw) | |
| 20848 | { | ||
| 20849 | ✗ | update_msgstr(); | |
| 20850 | ✗ | draw_screen(tmpscr); | |
| 20851 | ✗ | } | |
| 20852 | ✗ | FFCore.runGenericFrozenEngine(scr_id); | |
| 20853 | ✗ | return true; | |
| 20854 | } | ||
| 20855 | case MSGC_DRAWTILE: | ||
| 20856 | { | ||
| 20857 | ✗ | int32_t tl = grab_next_argument(); | |
| 20858 | ✗ | int32_t cs = grab_next_argument(); | |
| 20859 | ✗ | int32_t t_wid = grab_next_argument(); | |
| 20860 | ✗ | int32_t t_hei = grab_next_argument(); | |
| 20861 | ✗ | int32_t fl = grab_next_argument(); | |
| 20862 | |||
| 20863 | ✗ | if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right]) | |
| 20864 | { | ||
| 20865 | ✗ | ssc_tile_hei = ssc_tile_hei_buf; | |
| 20866 | ✗ | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); | |
| 20867 | ✗ | ssc_tile_hei_buf = -1; | |
| 20868 | ✗ | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 20869 | ✗ | if(bottom_margin_clip()) return true; | |
| 20870 | ✗ | cursor_x=msg_margins[left]; | |
| 20871 | ✗ | } | |
| 20872 | |||
| 20873 | ✗ | overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl); | |
| 20874 | ✗ | ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei); | |
| 20875 | ✗ | cursor_x += MsgStrings[msgstr].hspace + t_wid; | |
| 20876 | ✗ | return true; | |
| 20877 | } | ||
| 20878 | |||
| 20879 | case MSGC_GOTOIFRAND: | ||
| 20880 | { | ||
| 20881 | ✗ | int32_t odds = (int32_t)(grab_next_argument()); | |
| 20882 | |||
| 20883 | ✗ | if(!odds || !(zc_oldrand()%odds)) | |
| 20884 | ✗ | goto switched; | |
| 20885 | |||
| 20886 | ✗ | (void)grab_next_argument(); | |
| 20887 | ✗ | return true; | |
| 20888 | } | ||
| 20889 | |||
| 20890 | case MSGC_GOTOIFGLOBAL: | ||
| 20891 | { | ||
| 20892 | ✗ | int32_t arg = (int32_t)grab_next_argument(); | |
| 20893 | ✗ | int32_t d = zc_min(7,arg); | |
| 20894 | ✗ | int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff); | |
| 20895 | ✗ | arg = (int32_t)grab_next_argument(); | |
| 20896 | |||
| 20897 | ✗ | if(game->screen_d[s][d] >= arg) | |
| 20898 | ✗ | goto switched; | |
| 20899 | |||
| 20900 | ✗ | (void)grab_next_argument(); | |
| 20901 | ✗ | return true; | |
| 20902 | } | ||
| 20903 | |||
| 20904 | case MSGC_CHANGEPORTRAIT: | ||
| 20905 | { | ||
| 20906 | ✗ | return true; //not implemented | |
| 20907 | } | ||
| 20908 | |||
| 20909 | case MSGC_GOTOIFCREEND: | ||
| 20910 | { | ||
| 20911 | ✗ | int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here. | |
| 20912 | ✗ | int32_t screen = grab_next_argument(); | |
| 20913 | ✗ | int32_t reg = grab_next_argument(); | |
| 20914 | ✗ | int32_t val = grab_next_argument(); | |
| 20915 | //int32_t nxtstr = grab_next_argument(); | ||
| 20916 | ✗ | if ( FFCore.get_screen_d(screen + dmap, reg) >= val ) | |
| 20917 | { | ||
| 20918 | ✗ | goto switched; | |
| 20919 | } | ||
| 20920 | ✗ | (void)grab_next_argument(); | |
| 20921 | ✗ | return true; | |
| 20922 | } | ||
| 20923 | |||
| 20924 | case MSGC_GOTOIF: | ||
| 20925 | { | ||
| 20926 | ✗ | int32_t it = (int32_t)grab_next_argument(); | |
| 20927 | |||
| 20928 | ✗ | if(unsigned(it)<MAXITEMS && game->item[it]) | |
| 20929 | ✗ | goto switched; | |
| 20930 | |||
| 20931 | ✗ | (void)grab_next_argument(); | |
| 20932 | ✗ | return true; | |
| 20933 | } | ||
| 20934 | |||
| 20935 | case MSGC_GOTOIFCTR: | ||
| 20936 | { | ||
| 20937 | ✗ | if(game->get_counter(grab_next_argument())>=grab_next_argument()) | |
| 20938 | ✗ | goto switched; | |
| 20939 | |||
| 20940 | ✗ | (void)grab_next_argument(); | |
| 20941 | ✗ | return true; | |
| 20942 | } | ||
| 20943 | |||
| 20944 | case MSGC_GOTOIFCTRPC: | ||
| 20945 | { | ||
| 20946 | ✗ | int32_t counter = grab_next_argument(); | |
| 20947 | ✗ | int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter)); | |
| 20948 | |||
| 20949 | ✗ | if(game->get_counter(counter)>=amount) | |
| 20950 | ✗ | goto switched; | |
| 20951 | |||
| 20952 | ✗ | (void)grab_next_argument(); | |
| 20953 | ✗ | return true; | |
| 20954 | } | ||
| 20955 | |||
| 20956 | case MSGC_GOTOIFTRICOUNT: | ||
| 20957 | { | ||
| 20958 | ✗ | if(TriforceCount() >= (int32_t)(grab_next_argument())) | |
| 20959 | ✗ | goto switched; | |
| 20960 | |||
| 20961 | ✗ | (void)grab_next_argument(); | |
| 20962 | ✗ | return true; | |
| 20963 | } | ||
| 20964 | |||
| 20965 | case MSGC_GOTOIFTRI: | ||
| 20966 | { | ||
| 20967 | ✗ | int32_t lev = (int32_t)(grab_next_argument()); | |
| 20968 | |||
| 20969 | ✗ | if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE) | |
| 20970 | ✗ | goto switched; | |
| 20971 | |||
| 20972 | ✗ | (void)grab_next_argument(); | |
| 20973 | ✗ | return true; | |
| 20974 | } | ||
| 20975 | |||
| 20976 | case MSGC_SETUPMENU: | ||
| 20977 | { | ||
| 20978 | ✗ | msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument(); | |
| 20979 | ✗ | msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument(); | |
| 20980 | ✗ | msg_menu_data[MNU_CURSOR_WID] = grab_next_argument(); | |
| 20981 | ✗ | msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument(); | |
| 20982 | ✗ | msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument(); | |
| 20983 | ✗ | return true; | |
| 20984 | } | ||
| 20985 | |||
| 20986 | case MSGC_MENUCHOICE: | ||
| 20987 | { | ||
| 20988 | ✗ | int32_t pos = grab_next_argument(); | |
| 20989 | ✗ | int32_t upos = grab_next_argument(); | |
| 20990 | ✗ | int32_t dpos = grab_next_argument(); | |
| 20991 | ✗ | int32_t lpos = grab_next_argument(); | |
| 20992 | ✗ | int32_t rpos = grab_next_argument(); | |
| 20993 | ✗ | if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right]) | |
| 20994 | { | ||
| 20995 | ✗ | ssc_tile_hei = ssc_tile_hei_buf; | |
| 20996 | ✗ | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); | |
| 20997 | ✗ | ssc_tile_hei_buf = -1; | |
| 20998 | ✗ | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 20999 | ✗ | if(bottom_margin_clip()) break; | |
| 21000 | ✗ | cursor_x=msg_margins[left]; | |
| 21001 | ✗ | } | |
| 21002 | |||
| 21003 | ✗ | menu_options[pos] = menu_choice(cursor_x, cursor_y, pos, | |
| 21004 | ✗ | upos, dpos, lpos, rpos); | |
| 21005 | |||
| 21006 | ✗ | ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]); | |
| 21007 | ✗ | cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID]; | |
| 21008 | ✗ | return true; | |
| 21009 | } | ||
| 21010 | |||
| 21011 | case MSGC_RUNMENU: | ||
| 21012 | { | ||
| 21013 | ✗ | msg_menu_data[MNU_CHOSEN] = 0; | |
| 21014 | ✗ | msg_menu_data[MNU_CAN_CONFIRM] = 0; | |
| 21015 | ✗ | if(menu_options.size() < 1) | |
| 21016 | ✗ | return true; | |
| 21017 | ✗ | do_run_menu = true; | |
| 21018 | ✗ | return true; | |
| 21019 | } | ||
| 21020 | |||
| 21021 | case MSGC_GOTOMENUCHOICE: | ||
| 21022 | { | ||
| 21023 | ✗ | int32_t choice = grab_next_argument(); | |
| 21024 | ✗ | if(msg_menu_data[MNU_CHOSEN] == choice) | |
| 21025 | ✗ | goto switched; | |
| 21026 | ✗ | (void)grab_next_argument(); | |
| 21027 | ✗ | return true; | |
| 21028 | } | ||
| 21029 | |||
| 21030 | case MSGC_ENDSTRING: | ||
| 21031 | { | ||
| 21032 | ✗ | do_end_str = true; | |
| 21033 | ✗ | return true; | |
| 21034 | } | ||
| 21035 | case MSGC_WAIT_ADVANCE: | ||
| 21036 | { | ||
| 21037 | ✗ | wait_advance = true; | |
| 21038 | ✗ | linkedmsgclk = 51; | |
| 21039 | ✗ | return true; | |
| 21040 | } | ||
| 21041 | case MSGC_TRIGSECRETS: | ||
| 21042 | { | ||
| 21043 | ✗ | bool perm = (bool)grab_next_argument(); | |
| 21044 | ✗ | hidden_entrance(0, true, false, -8); | |
| 21045 | ✗ | if(perm) | |
| 21046 | ✗ | setmapflag(mSECRET); | |
| 21047 | ✗ | return true; | |
| 21048 | } | ||
| 21049 | case MSGC_TRIG_CMB_COPYCAT: | ||
| 21050 | { | ||
| 21051 | ✗ | int copy_id = (int)grab_next_argument(); | |
| 21052 | ✗ | if(copy_id == byte(copy_id)) | |
| 21053 | ✗ | trig_copycat(copy_id); | |
| 21054 | ✗ | return true; | |
| 21055 | } | ||
| 21056 | case MSGC_SETSCREENSTATE: | ||
| 21057 | { | ||
| 21058 | ✗ | int32_t flag = int32_t(grab_next_argument()); | |
| 21059 | ✗ | if(unsigned(flag)>=mMAXIND) | |
| 21060 | { | ||
| 21061 | ✗ | Z_error("SCC 133: Flag %d is invalid\n", flag); | |
| 21062 | ✗ | return true; | |
| 21063 | } | ||
| 21064 | ✗ | bool state = bool(grab_next_argument()); | |
| 21065 | ✗ | if(state) | |
| 21066 | ✗ | setmapflag(1<<flag); | |
| 21067 | else | ||
| 21068 | ✗ | unsetmapflag(1<<flag,true); | |
| 21069 | ✗ | return true; | |
| 21070 | } | ||
| 21071 | case MSGC_SETSCREENSTATER: | ||
| 21072 | { | ||
| 21073 | ✗ | int32_t map = (int32_t)grab_next_argument(); | |
| 21074 | ✗ | int32_t scrid = (int32_t)grab_next_argument(); | |
| 21075 | ✗ | if(map < 1 || map > map_count) | |
| 21076 | { | ||
| 21077 | ✗ | Z_error("SCC 134: Map %d is invalid\n", map); | |
| 21078 | ✗ | return true; | |
| 21079 | } | ||
| 21080 | ✗ | if(unsigned(scrid)>=0x80) | |
| 21081 | { | ||
| 21082 | ✗ | Z_error("SCC 134: Screen %d is invalid\n", scrid); | |
| 21083 | ✗ | return true; | |
| 21084 | } | ||
| 21085 | |||
| 21086 | ✗ | int32_t flag = int32_t(grab_next_argument()); | |
| 21087 | ✗ | if(unsigned(flag)>=mMAXIND) | |
| 21088 | { | ||
| 21089 | ✗ | Z_error("SCC 134: Flag %d is invalid\n", flag); | |
| 21090 | ✗ | return true; | |
| 21091 | } | ||
| 21092 | ✗ | bool state = bool(grab_next_argument()); | |
| 21093 | ✗ | if(state) | |
| 21094 | ✗ | setmapflag(mapind(map,scrid),1<<flag); | |
| 21095 | else | ||
| 21096 | ✗ | unsetmapflag(mapind(map,scrid),1<<flag,true); | |
| 21097 | ✗ | return true; | |
| 21098 | } | ||
| 21099 | switched: | ||
| 21100 | ✗ | int32_t lev = (int32_t)(grab_next_argument()); | |
| 21101 | ✗ | if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG) | |
| 21102 | ✗ | && (MsgStrings[lev].stringflags & STRINGFLAG_CONT)) | |
| 21103 | { | ||
| 21104 | ✗ | msgstr=lev; | |
| 21105 | ✗ | msgpos=msgptr=0; | |
| 21106 | ✗ | msgfont=setmsgfont(); | |
| 21107 | ✗ | } | |
| 21108 | else | ||
| 21109 | { | ||
| 21110 | ✗ | donewmsg(lev); | |
| 21111 | ✗ | ssc_tile_hei_buf = -1; | |
| 21112 | } | ||
| 21113 | ✗ | msgptr--; // To counteract it being incremented after this routine is called. | |
| 21114 | ✗ | putprices(false); | |
| 21115 | ✗ | return true; | |
| 21116 | } | ||
| 21117 | |||
| 21118 | 6197 | return false; | |
| 21119 | 6341 | } | |
| 21120 | |||
| 21121 | // Wraps the message string... probably. | ||
| 21122 | 6174 | void wrapmsgstr(char *s3) | |
| 21123 | { | ||
| 21124 | 6174 | int32_t j=0; | |
| 21125 | |||
| 21126 |
2/2✓ Branch 0 taken 2326 times.
✓ Branch 1 taken 3848 times.
|
6174 | if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP) |
| 21127 | { | ||
| 21128 |
2/2✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1894 times.
|
2326 | if(msgspace) |
| 21129 | { | ||
| 21130 | 432 | char c = MsgStrings[msgstr].s[msgptr]; | |
| 21131 |
3/6✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 432 times.
✗ Branch 5 not taken.
|
432 | if(c != ' ' && c >= 32 && c <= 126) |
| 21132 | { | ||
| 21133 |
4/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2390 times.
✓ Branch 2 taken 1962 times.
✓ Branch 3 taken 432 times.
|
2394 | for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++) |
| 21134 | { | ||
| 21135 |
3/4✓ Branch 0 taken 1954 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1954 times.
|
1962 | if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k]; |
| 21136 | 1962 | } | |
| 21137 | |||
| 21138 | 432 | s3[j] = 0; | |
| 21139 | 432 | msgspace = false; | |
| 21140 | 432 | } | |
| 21141 | else | ||
| 21142 | { | ||
| 21143 | ✗ | s3[0] = c; | |
| 21144 | ✗ | s3[1] = 0; | |
| 21145 | } | ||
| 21146 | 432 | } | |
| 21147 | else | ||
| 21148 | { | ||
| 21149 | 1894 | s3[0] = MsgStrings[msgstr].s[msgptr]; | |
| 21150 | 1894 | s3[1] = 0; | |
| 21151 | |||
| 21152 |
2/2✓ Branch 0 taken 1522 times.
✓ Branch 1 taken 372 times.
|
1894 | if(s3[0] == ' ') msgspace=true; |
| 21153 | } | ||
| 21154 | 2326 | } | |
| 21155 | else | ||
| 21156 | { | ||
| 21157 | 3848 | s3[0] = MsgStrings[msgstr].s[msgptr]; | |
| 21158 | 3848 | s3[1] = 0; | |
| 21159 | } | ||
| 21160 | 6174 | } | |
| 21161 | |||
| 21162 | // Returns true if the pointer is at a string's | ||
| 21163 | // null terminator or a trailing space | ||
| 21164 | 27132 | bool atend(char const* str) | |
| 21165 | { | ||
| 21166 | 27132 | int32_t i=0; | |
| 21167 | |||
| 21168 |
2/2✓ Branch 0 taken 414104 times.
✓ Branch 1 taken 27132 times.
|
441236 | while(str[i]==' ') |
| 21169 | 414104 | i++; | |
| 21170 | |||
| 21171 | 27132 | return str[i]=='\0'; | |
| 21172 | } | ||
| 21173 | |||
| 21174 | 801024 | void putmsg() | |
| 21175 | { | ||
| 21176 | 801024 | bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0; | |
| 21177 |
2/2✓ Branch 0 taken 31892 times.
✓ Branch 1 taken 769132 times.
|
801024 | if(!msgorig) msgorig=msgstr; |
| 21178 | |||
| 21179 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 801024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
801024 | if(wait_advance && linkedmsgclk < 1) |
| 21180 | ✗ | linkedmsgclk = 1; | |
| 21181 |
2/2✓ Branch 0 taken 786450 times.
✓ Branch 1 taken 14574 times.
|
801024 | if(linkedmsgclk>0) |
| 21182 | { | ||
| 21183 |
2/2✓ Branch 0 taken 9908 times.
✓ Branch 1 taken 4666 times.
|
14574 | if(linkedmsgclk==1) |
| 21184 | { | ||
| 21185 |
5/6✓ Branch 0 taken 9908 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9819 times.
✓ Branch 3 taken 89 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 9817 times.
|
9908 | if(do_end_str||cAbtn()||cBbtn()) |
| 21186 | { | ||
| 21187 | 91 | do_end_str = false; | |
| 21188 | 91 | linkedmsgclk = 0; | |
| 21189 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
|
91 | if(wait_advance) |
| 21190 | { | ||
| 21191 | ✗ | wait_advance = false; | |
| 21192 | ✗ | } | |
| 21193 | else | ||
| 21194 | { | ||
| 21195 | 91 | msgstr=MsgStrings[msgstr].nextstring; | |
| 21196 | 91 | ssc_tile_hei_buf = -1; | |
| 21197 |
3/4✓ Branch 0 taken 62 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
|
91 | if(!msgstr && enqueued_str) |
| 21198 | { | ||
| 21199 | ✗ | msgstr = enqueued_str; | |
| 21200 | ✗ | enqueued_str = 0; | |
| 21201 | ✗ | } | |
| 21202 |
2/2✓ Branch 0 taken 29 times.
✓ Branch 1 taken 62 times.
|
91 | if(!msgstr) |
| 21203 | { | ||
| 21204 | 62 | msgfont=get_zc_font(font_zfont); | |
| 21205 | |||
| 21206 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 60 times.
|
62 | if(tmpscr->room!=rGRUMBLE) |
| 21207 | 60 | blockpath=false; | |
| 21208 | |||
| 21209 | 62 | dismissmsg(); | |
| 21210 | 62 | goto disappear; | |
| 21211 | } | ||
| 21212 | |||
| 21213 | 29 | donewmsg(msgstr); | |
| 21214 | 29 | putprices(false); | |
| 21215 | } | ||
| 21216 | 29 | } | |
| 21217 | 9846 | } | |
| 21218 | else | ||
| 21219 | { | ||
| 21220 | 4666 | --linkedmsgclk; | |
| 21221 | } | ||
| 21222 | 14512 | } | |
| 21223 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 800962 times.
|
800962 | if(wait_advance) return; //Waiting for buttonpress |
| 21224 | |||
| 21225 |
9/10✓ Branch 0 taken 800864 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 31625 times.
✓ Branch 3 taken 769239 times.
✓ Branch 4 taken 30651 times.
✓ Branch 5 taken 974 times.
✓ Branch 6 taken 13376 times.
✓ Branch 7 taken 17275 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 13376 times.
|
800962 | if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip())) |
| 21226 | { | ||
| 21227 |
2/2✓ Branch 0 taken 18249 times.
✓ Branch 1 taken 769239 times.
|
787488 | if(!msgstr) |
| 21228 | 769239 | msgorig=0; | |
| 21229 | |||
| 21230 | 787488 | msg_active = false; | |
| 21231 | 787488 | return; | |
| 21232 | } | ||
| 21233 | |||
| 21234 | 13474 | msg_onscreen = true; // Now the message is onscreen (see donewmsg()). | |
| 21235 | |||
| 21236 | char s3[145]; | ||
| 21237 | int32_t tlength; | ||
| 21238 | |||
| 21239 | // Bypass the string with the B button! | ||
| 21240 |
4/4✓ Branch 0 taken 60 times.
✓ Branch 1 taken 13414 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 13364 times.
|
13474 | if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0) |
| 21241 | { | ||
| 21242 | //finish writing out the string | ||
| 21243 |
4/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 640 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 629 times.
|
739 | while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr)) |
| 21244 | { | ||
| 21245 |
4/6✓ Branch 0 taken 142 times.
✓ Branch 1 taken 487 times.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 142 times.
✗ Branch 5 not taken.
|
629 | if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS))) |
| 21246 | ✗ | goto breakout; // break out if message speed was changed to non-zero | |
| 21247 |
3/6✓ Branch 0 taken 629 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 629 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 629 times.
|
629 | else if(!do_run_menu && !doing_name_insert && !parsemsgcode()) |
| 21248 | { | ||
| 21249 |
1/2✓ Branch 0 taken 629 times.
✗ Branch 1 not taken.
|
629 | if(bottom_margin_clip()) |
| 21250 | ✗ | break; | |
| 21251 | |||
| 21252 | 629 | wrapmsgstr(s3); | |
| 21253 | |||
| 21254 |
2/2✓ Branch 0 taken 125 times.
✓ Branch 1 taken 504 times.
|
629 | if(MsgStrings[msgstr].s[msgptr]==' ') |
| 21255 | { | ||
| 21256 | 125 | tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace; | |
| 21257 | |||
| 21258 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
132 | if(cursor_x+tlength > (msg_w-msg_margins[right]) |
| 21259 |
4/6✓ Branch 0 taken 7 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
|
125 | && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) |
| 21260 | ✗ | ? true : strcmp(s3," ")!=0)) | |
| 21261 | { | ||
| 21262 | 7 | ssc_tile_hei = ssc_tile_hei_buf; | |
| 21263 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); |
| 21264 | 7 | ssc_tile_hei_buf = -1; | |
| 21265 | 7 | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 21266 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if(bottom_margin_clip()) break; |
| 21267 | 7 | cursor_x=msg_margins[left]; | |
| 21268 | 7 | } | |
| 21269 | |||
| 21270 | 125 | char buf[2] = {0}; | |
| 21271 | 125 | sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]); | |
| 21272 | |||
| 21273 | 125 | textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1); | |
| 21274 | |||
| 21275 | 125 | cursor_x+=tlength; | |
| 21276 | 125 | } | |
| 21277 | else | ||
| 21278 | { | ||
| 21279 | 504 | tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace); | |
| 21280 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
|
514 | if(cursor_x+tlength > (msg_w-msg_margins[right]) |
| 21281 |
4/6✓ Branch 0 taken 10 times.
✓ Branch 1 taken 494 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
|
504 | && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) |
| 21282 | 4 | ? true : strcmp(s3," ")!=0)) | |
| 21283 | { | ||
| 21284 | 10 | ssc_tile_hei = ssc_tile_hei_buf; | |
| 21285 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); |
| 21286 | 10 | ssc_tile_hei_buf = -1; | |
| 21287 | 10 | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 21288 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | if(bottom_margin_clip()) break; |
| 21289 | 10 | cursor_x=msg_margins[left]; | |
| 21290 | 10 | } | |
| 21291 | |||
| 21292 | 504 | sfx(MsgStrings[msgstr].sfx); | |
| 21293 | |||
| 21294 | 504 | char buf[2] = {0}; | |
| 21295 | 504 | sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]); | |
| 21296 | |||
| 21297 | 504 | textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1); | |
| 21298 | |||
| 21299 | 504 | cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]); | |
| 21300 | 504 | cursor_x += MsgStrings[msgstr].hspace; | |
| 21301 | } | ||
| 21302 | |||
| 21303 | 629 | msgpos++; | |
| 21304 | 629 | } | |
| 21305 |
1/2✓ Branch 0 taken 629 times.
✗ Branch 1 not taken.
|
629 | if(do_run_menu) |
| 21306 | { | ||
| 21307 | ✗ | if(runMenuCursor()) | |
| 21308 | { | ||
| 21309 | ✗ | do_run_menu = false; | |
| 21310 | ✗ | } | |
| 21311 | ✗ | else break; | |
| 21312 | ✗ | } | |
| 21313 |
1/2✓ Branch 0 taken 629 times.
✗ Branch 1 not taken.
|
629 | if(doing_name_insert) |
| 21314 | { | ||
| 21315 | ✗ | if(*nameptr) | |
| 21316 | { | ||
| 21317 | ✗ | if(bottom_margin_clip()) | |
| 21318 | ✗ | break; | |
| 21319 | |||
| 21320 | ✗ | char s3[9] = {0}; | |
| 21321 | |||
| 21322 | ✗ | if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP) | |
| 21323 | { | ||
| 21324 | ✗ | strcpy(s3, nameptr); | |
| 21325 | ✗ | } | |
| 21326 | else | ||
| 21327 | { | ||
| 21328 | ✗ | s3[0] = *nameptr; | |
| 21329 | ✗ | s3[1] = 0; | |
| 21330 | } | ||
| 21331 | |||
| 21332 | ✗ | tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace); | |
| 21333 | |||
| 21334 | ✗ | if(cursor_x+tlength > (msg_w-msg_margins[right]) | |
| 21335 | ✗ | && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) | |
| 21336 | ✗ | ? true : strcmp(s3," ")!=0)) | |
| 21337 | { | ||
| 21338 | ✗ | ssc_tile_hei = ssc_tile_hei_buf; | |
| 21339 | ✗ | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); | |
| 21340 | ✗ | ssc_tile_hei_buf = -1; | |
| 21341 | ✗ | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 21342 | ✗ | if(bottom_margin_clip()) break; | |
| 21343 | ✗ | cursor_x=msg_margins[left]; | |
| 21344 | ✗ | } | |
| 21345 | |||
| 21346 | ✗ | sfx(MsgStrings[msgstr].sfx); | |
| 21347 | |||
| 21348 | ✗ | char buf[2] = {0}; | |
| 21349 | ✗ | sprintf(buf,"%c",*nameptr); | |
| 21350 | |||
| 21351 | ✗ | textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1); | |
| 21352 | |||
| 21353 | ✗ | cursor_x += msgfont->vtable->char_length(msgfont, *nameptr); | |
| 21354 | ✗ | cursor_x += MsgStrings[msgstr].hspace; | |
| 21355 | ✗ | ++nameptr; | |
| 21356 | ✗ | continue; //don't advance the msgptr, as the next char in it was not processed! | |
| 21357 | } | ||
| 21358 | ✗ | else doing_name_insert = false; | |
| 21359 | ✗ | } | |
| 21360 | 629 | ++msgptr; | |
| 21361 |
1/2✓ Branch 0 taken 629 times.
✗ Branch 1 not taken.
|
629 | if(do_end_str) |
| 21362 | ✗ | goto strendcheck; | |
| 21363 |
1/2✓ Branch 0 taken 629 times.
✗ Branch 1 not taken.
|
629 | if(wait_advance) |
| 21364 | ✗ | return; | |
| 21365 |
2/2✓ Branch 0 taken 617 times.
✓ Branch 1 taken 12 times.
|
629 | if(atend(MsgStrings[msgstr].s.c_str()+msgptr)) |
| 21366 | { | ||
| 21367 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 7 times.
|
12 | if(MsgStrings[msgstr].nextstring) |
| 21368 | { | ||
| 21369 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT) |
| 21370 | { | ||
| 21371 | ✗ | msgstr=MsgStrings[msgstr].nextstring; | |
| 21372 | ✗ | msgpos=msgptr=0; | |
| 21373 | ✗ | msgfont=setmsgfont(); | |
| 21374 | ✗ | } | |
| 21375 | 7 | } | |
| 21376 | 12 | } | |
| 21377 | } | ||
| 21378 | |||
| 21379 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (!do_run_menu) |
| 21380 | { | ||
| 21381 | 12 | msgclk = 72; | |
| 21382 | 12 | msgpos = 10000; | |
| 21383 | 12 | } | |
| 21384 | 12 | } | |
| 21385 | else | ||
| 21386 | 13364 | { | |
| 21387 | breakout: | ||
| 21388 | 13364 | word tempspeed = msgspeed; | |
| 21389 |
1/2✓ Branch 0 taken 13364 times.
✗ Branch 1 not taken.
|
13364 | if (do_run_menu) |
| 21390 | ✗ | tempspeed = 0; | |
| 21391 |
6/6✓ Branch 0 taken 11020 times.
✓ Branch 1 taken 2344 times.
✓ Branch 2 taken 4560 times.
✓ Branch 3 taken 6460 times.
✓ Branch 4 taken 3354 times.
✓ Branch 5 taken 1206 times.
|
13364 | if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG)))) |
| 21392 | 7666 | return; | |
| 21393 | } | ||
| 21394 | |||
| 21395 | // Start writing the string | ||
| 21396 |
2/2✓ Branch 0 taken 5573 times.
✓ Branch 1 taken 137 times.
|
5847 | if(msgptr == 0) |
| 21397 | { | ||
| 21398 |
2/2✓ Branch 0 taken 137 times.
✓ Branch 1 taken 133 times.
|
270 | while(MsgStrings[msgstr].s[msgptr]==' ') |
| 21399 | { | ||
| 21400 | 133 | tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace; | |
| 21401 | |||
| 21402 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
134 | if(cursor_x+tlength > (msg_w-msg_margins[right]) |
| 21403 |
4/6✓ Branch 0 taken 132 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
133 | && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) |
| 21404 | ✗ | ? 1 : strcmp(s3," ")!=0)) | |
| 21405 | { | ||
| 21406 | 1 | ssc_tile_hei = ssc_tile_hei_buf; | |
| 21407 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); |
| 21408 | 1 | ssc_tile_hei_buf = -1; | |
| 21409 | 1 | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 21410 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(bottom_margin_clip()) break; |
| 21411 | 1 | cursor_x=msg_margins[left]; | |
| 21412 | 1 | } | |
| 21413 | |||
| 21414 | 133 | cursor_x+=tlength; | |
| 21415 | 133 | ++msgptr; | |
| 21416 | 133 | ++msgpos; | |
| 21417 | |||
| 21418 | // The "Continue From Previous" feature | ||
| 21419 |
1/2✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
|
133 | if(atend(MsgStrings[msgstr].s.c_str()+msgptr)) |
| 21420 | { | ||
| 21421 | ✗ | if(MsgStrings[msgstr].nextstring) | |
| 21422 | { | ||
| 21423 | ✗ | if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT) | |
| 21424 | { | ||
| 21425 | ✗ | msgstr=MsgStrings[msgstr].nextstring; | |
| 21426 | ✗ | msgpos=msgptr=0; | |
| 21427 | ✗ | msgfont=setmsgfont(); | |
| 21428 | ✗ | } | |
| 21429 | ✗ | } | |
| 21430 | ✗ | } | |
| 21431 | } | ||
| 21432 | 137 | } | |
| 21433 | |||
| 21434 | reparsesinglechar: | ||
| 21435 | // Continue printing the string! | ||
| 21436 |
3/4✓ Branch 0 taken 5562 times.
✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5562 times.
|
11272 | if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip()) |
| 21437 | { | ||
| 21438 |
4/6✓ Branch 0 taken 5562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5562 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
✓ Branch 5 taken 5545 times.
|
5562 | if(!do_run_menu && !doing_name_insert && !parsemsgcode()) |
| 21439 | { | ||
| 21440 | 5545 | wrapmsgstr(s3); | |
| 21441 | |||
| 21442 | 5545 | tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace); | |
| 21443 | |||
| 21444 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 35 times.
|
5634 | if(cursor_x+tlength > (msg_w-msg_margins[right]) |
| 21445 |
6/6✓ Branch 0 taken 104 times.
✓ Branch 1 taken 5441 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 15 times.
|
5545 | && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) |
| 21446 | 54 | ? true : strcmp(s3," ")!=0)) | |
| 21447 | { | ||
| 21448 | 89 | ssc_tile_hei = ssc_tile_hei_buf; | |
| 21449 |
1/2✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
|
89 | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); |
| 21450 | 89 | ssc_tile_hei_buf = -1; | |
| 21451 | 89 | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 21452 |
1/2✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
|
89 | if(bottom_margin_clip()) goto strendcheck; |
| 21453 | 89 | cursor_x=msg_margins[left]; | |
| 21454 | //if(space) s3[0]=0; | ||
| 21455 | 89 | } | |
| 21456 | |||
| 21457 | 5545 | sfx(MsgStrings[msgstr].sfx); | |
| 21458 | |||
| 21459 | 5545 | char buf[2] = {0}; | |
| 21460 | 5545 | sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]); | |
| 21461 | |||
| 21462 | 5545 | textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1); | |
| 21463 | |||
| 21464 | 5545 | cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]); | |
| 21465 | 5545 | cursor_x += MsgStrings[msgstr].hspace; | |
| 21466 | 5545 | msgpos++; | |
| 21467 | 5545 | } | |
| 21468 |
1/2✓ Branch 0 taken 5562 times.
✗ Branch 1 not taken.
|
5562 | if(do_end_str) |
| 21469 | ✗ | goto strendcheck; | |
| 21470 |
1/2✓ Branch 0 taken 5562 times.
✗ Branch 1 not taken.
|
5562 | if(wait_advance) |
| 21471 | { | ||
| 21472 | ✗ | ++msgptr; | |
| 21473 | ✗ | return; | |
| 21474 | } | ||
| 21475 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5562 times.
|
5562 | else if(do_run_menu) |
| 21476 | { | ||
| 21477 | ✗ | if(runMenuCursor()) | |
| 21478 | { | ||
| 21479 | ✗ | do_run_menu = false; | |
| 21480 | ✗ | ++msgptr; | |
| 21481 | ✗ | goto reparsesinglechar; | |
| 21482 | } | ||
| 21483 | ✗ | } | |
| 21484 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 5562 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
5562 | else if(doing_name_insert && *nameptr) |
| 21485 | { | ||
| 21486 | ✗ | char s3[9] = {0}; | |
| 21487 | |||
| 21488 | ✗ | if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP) | |
| 21489 | { | ||
| 21490 | ✗ | strcpy(s3, nameptr); | |
| 21491 | ✗ | } | |
| 21492 | else | ||
| 21493 | { | ||
| 21494 | ✗ | s3[0] = *nameptr; | |
| 21495 | ✗ | s3[1] = 0; | |
| 21496 | } | ||
| 21497 | |||
| 21498 | ✗ | tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace); | |
| 21499 | |||
| 21500 | ✗ | if(cursor_x+tlength > (msg_w-msg_margins[right]) | |
| 21501 | ✗ | && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) | |
| 21502 | ✗ | ? true : strcmp(s3," ")!=0)) | |
| 21503 | { | ||
| 21504 | ✗ | ssc_tile_hei = ssc_tile_hei_buf; | |
| 21505 | ✗ | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); | |
| 21506 | ✗ | ssc_tile_hei_buf = -1; | |
| 21507 | ✗ | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 21508 | ✗ | if(bottom_margin_clip()) goto strendcheck; | |
| 21509 | ✗ | cursor_x=msg_margins[left]; | |
| 21510 | ✗ | } | |
| 21511 | |||
| 21512 | ✗ | sfx(MsgStrings[msgstr].sfx); | |
| 21513 | |||
| 21514 | ✗ | char buf[2] = {0}; | |
| 21515 | ✗ | sprintf(buf,"%c",*nameptr); | |
| 21516 | |||
| 21517 | ✗ | textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1); | |
| 21518 | |||
| 21519 | ✗ | cursor_x += msgfont->vtable->char_length(msgfont, *nameptr); | |
| 21520 | ✗ | cursor_x += MsgStrings[msgstr].hspace; | |
| 21521 | ✗ | ++nameptr; | |
| 21522 | ✗ | } | |
| 21523 | else | ||
| 21524 | { | ||
| 21525 | 5562 | doing_name_insert = false; | |
| 21526 | 5562 | msgptr++; | |
| 21527 | |||
| 21528 |
2/2✓ Branch 0 taken 5432 times.
✓ Branch 1 taken 130 times.
|
5562 | if(atend(MsgStrings[msgstr].s.c_str()+msgptr)) |
| 21529 | { | ||
| 21530 |
2/2✓ Branch 0 taken 103 times.
✓ Branch 1 taken 27 times.
|
130 | if(MsgStrings[msgstr].nextstring) |
| 21531 | { | ||
| 21532 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT) |
| 21533 | { | ||
| 21534 | ✗ | msgstr=MsgStrings[msgstr].nextstring; | |
| 21535 | ✗ | msgpos=msgptr=0; | |
| 21536 | ✗ | msgfont=setmsgfont(); | |
| 21537 | ✗ | } | |
| 21538 | 27 | } | |
| 21539 | 130 | } | |
| 21540 | |||
| 21541 |
2/2✓ Branch 0 taken 839 times.
✓ Branch 1 taken 177 times.
|
6578 | if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1) |
| 21542 |
2/2✓ Branch 0 taken 5546 times.
✓ Branch 1 taken 16 times.
|
5562 | && (MsgStrings[msgstr].s[msgptr]==' ') |
| 21543 |
2/2✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4530 times.
|
5546 | && (MsgStrings[msgstr].s[msgptr+1]==' ')) |
| 21544 | { | ||
| 21545 |
2/2✓ Branch 0 taken 177 times.
✓ Branch 1 taken 8886 times.
|
9063 | while(MsgStrings[msgstr].s[msgptr]==' ') |
| 21546 | { | ||
| 21547 | 8886 | msgspace = true; | |
| 21548 | 8886 | tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace; | |
| 21549 | |||
| 21550 |
2/2✓ Branch 0 taken 217 times.
✓ Branch 1 taken 152 times.
|
9255 | if(cursor_x+tlength > (msg_w-msg_margins[right]) |
| 21551 |
4/6✓ Branch 0 taken 369 times.
✓ Branch 1 taken 8517 times.
✓ Branch 2 taken 369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 152 times.
✗ Branch 5 not taken.
|
8886 | && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) |
| 21552 | 217 | ? true : strcmp(s3," ")!=0)) | |
| 21553 | { | ||
| 21554 | 369 | ssc_tile_hei = ssc_tile_hei_buf; | |
| 21555 |
1/2✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
|
369 | int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont)); |
| 21556 | 369 | ssc_tile_hei_buf = -1; | |
| 21557 | 369 | cursor_y += thei + MsgStrings[msgstr].vspace; | |
| 21558 |
1/2✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
|
369 | if(bottom_margin_clip()) break; |
| 21559 | 369 | cursor_x=msg_margins[left]; | |
| 21560 | 369 | } | |
| 21561 | |||
| 21562 | 8886 | cursor_x+=tlength; | |
| 21563 | 8886 | ++msgpos; | |
| 21564 | 8886 | ++msgptr; | |
| 21565 | |||
| 21566 |
2/2✓ Branch 0 taken 291 times.
✓ Branch 1 taken 8595 times.
|
8886 | if(atend(MsgStrings[msgstr].s.c_str()+msgptr)) |
| 21567 | { | ||
| 21568 |
2/2✓ Branch 0 taken 7338 times.
✓ Branch 1 taken 1257 times.
|
8595 | if(MsgStrings[msgstr].nextstring) |
| 21569 | { | ||
| 21570 |
1/2✓ Branch 0 taken 1257 times.
✗ Branch 1 not taken.
|
1257 | if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT) |
| 21571 | { | ||
| 21572 | ✗ | msgstr=MsgStrings[msgstr].nextstring; | |
| 21573 | ✗ | msgpos=msgptr=0; | |
| 21574 | ✗ | msgfont=setmsgfont(); | |
| 21575 | ✗ | } | |
| 21576 | 1257 | } | |
| 21577 | 8595 | } | |
| 21578 | } | ||
| 21579 | 177 | } | |
| 21580 | } | ||
| 21581 | 5562 | } | |
| 21582 | strendcheck: | ||
| 21583 | // Done printing the string | ||
| 21584 |
10/14✓ Branch 0 taken 5710 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5710 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5710 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5698 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 5572 times.
✓ Branch 9 taken 126 times.
✓ Branch 10 taken 5572 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5560 times.
✓ Branch 13 taken 150 times.
|
5710 | if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk) |
| 21585 | { | ||
| 21586 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
|
150 | if(!do_end_str) |
| 21587 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
|
150 | while(parsemsgcode()); // Finish remaining control codes |
| 21588 | |||
| 21589 | // Go to next string, or make it disappear by going to string 0. | ||
| 21590 |
5/6✓ Branch 0 taken 116 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
|
150 | if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str) |
| 21591 | { | ||
| 21592 | 96 | linkedmsgclk=do_end_str?1:51; | |
| 21593 | 96 | } | |
| 21594 | |||
| 21595 |
2/2✓ Branch 0 taken 116 times.
✓ Branch 1 taken 34 times.
|
150 | if(MsgStrings[msgstr].nextstring==0) |
| 21596 | { | ||
| 21597 |
2/2✓ Branch 0 taken 62 times.
✓ Branch 1 taken 54 times.
|
116 | if(!get_qr(qr_MSGDISAPPEAR)) |
| 21598 | 54 | { | |
| 21599 | disappear: | ||
| 21600 | 116 | msg_active = false; | |
| 21601 | 116 | Hero.finishedmsg(); | |
| 21602 | 116 | } | |
| 21603 | |||
| 21604 |
1/2✓ Branch 0 taken 178 times.
✗ Branch 1 not taken.
|
178 | if(repaircharge) |
| 21605 | { | ||
| 21606 | // if (get_qr(qr_REPAIRFIX)) { | ||
| 21607 | // fixed_door=true; | ||
| 21608 | // } | ||
| 21609 | ✗ | game->change_drupy(-tmpscr[currscr<128?0:1].catchall); | |
| 21610 | ✗ | repaircharge = 0; | |
| 21611 | ✗ | } | |
| 21612 | |||
| 21613 |
1/2✓ Branch 0 taken 178 times.
✗ Branch 1 not taken.
|
178 | if(adjustmagic) |
| 21614 | { | ||
| 21615 | ✗ | if(get_qr(qr_OLD_HALF_MAGIC)) | |
| 21616 | { | ||
| 21617 | ✗ | if(game->get_magicdrainrate()) | |
| 21618 | ✗ | game->set_magicdrainrate(1); | |
| 21619 | ✗ | } | |
| 21620 | ✗ | else if(game->get_magicdrainrate() > 1) | |
| 21621 | { | ||
| 21622 | ✗ | game->set_magicdrainrate(game->get_magicdrainrate()/2); | |
| 21623 | ✗ | } | |
| 21624 | ✗ | adjustmagic = false; | |
| 21625 | ✗ | sfx(WAV_SCALE); | |
| 21626 | ✗ | setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM); | |
| 21627 | ✗ | } | |
| 21628 | |||
| 21629 |
1/2✓ Branch 0 taken 178 times.
✗ Branch 1 not taken.
|
178 | if(learnslash) |
| 21630 | { | ||
| 21631 | ✗ | game->set_canslash(1); | |
| 21632 | ✗ | learnslash = false; | |
| 21633 | ✗ | sfx(WAV_SCALE); | |
| 21634 | ✗ | setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM); | |
| 21635 | ✗ | } | |
| 21636 | 178 | } | |
| 21637 | 212 | } | |
| 21638 | 800926 | } | |
| 21639 | |||
| 21640 | 9816 | int32_t message_more_y() | |
| 21641 | { | ||
| 21642 | //Is the flag ticked, do we really want a message more y larger than 160? | ||
| 21643 |
5/6✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9802 times.
✓ Branch 2 taken 9816 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9802 times.
✓ Branch 5 taken 14 times.
|
9816 | int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160); |
| 21644 | 9816 | msgy+=playing_field_offset; | |
| 21645 | 9816 | return msgy; | |
| 21646 | } | ||
| 21647 | |||
| 21648 | /*** Collision detection & handling ***/ | ||
| 21649 | |||
| 21650 | 783670 | void clear_script_one_frame_conditions() | |
| 21651 | { | ||
| 21652 |
2/2✓ Branch 0 taken 854799 times.
✓ Branch 1 taken 783670 times.
|
1638469 | for(int32_t j=0; j<guys.Count(); j++) |
| 21653 | { | ||
| 21654 | 854799 | enemy *e = (enemy*)guys.spr(j); | |
| 21655 |
2/2✓ Branch 0 taken 14531583 times.
✓ Branch 1 taken 854799 times.
|
15386382 | for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0; |
| 21656 | 854799 | } | |
| 21657 | 783670 | } | |
| 21658 | |||
| 21659 | 145379 | void check_enemy_lweapon_collision(weapon *w) | |
| 21660 | { | ||
| 21661 |
7/8✓ Branch 0 taken 129985 times.
✓ Branch 1 taken 15394 times.
✓ Branch 2 taken 93891 times.
✓ Branch 3 taken 36094 times.
✓ Branch 4 taken 89570 times.
✓ Branch 5 taken 4321 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 89570 times.
|
145379 | if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand) |
| 21662 | { | ||
| 21663 |
2/2✓ Branch 0 taken 89165 times.
✓ Branch 1 taken 101943 times.
|
191108 | for(int32_t j=0; j<guys.Count(); j++) |
| 21664 | { | ||
| 21665 | 101943 | enemy *e = (enemy*)guys.spr(j); | |
| 21666 | |||
| 21667 | 101943 | bool didhit = e->hit(w); | |
| 21668 |
2/2✓ Branch 0 taken 99496 times.
✓ Branch 1 taken 2447 times.
|
101943 | if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame, |
| 21669 | //because this only checks `if(dying || clk<0 || hclk>0 || superman)` | ||
| 21670 | { | ||
| 21671 | // !(e->stunclk) | ||
| 21672 | 2447 | int32_t h = e->takehit(w); | |
| 21673 |
2/2✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 798 times.
|
2447 | if (h == -1) |
| 21674 | { | ||
| 21675 | 798 | int indx = Lwpns.find(w); | |
| 21676 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 798 times.
|
798 | if(indx > -1) |
| 21677 | 798 | e->hitby[HIT_BY_LWEAPON] = indx+1; | |
| 21678 | 798 | e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID; | |
| 21679 | 798 | e->hitby[HIT_BY_LWEAPON_TYPE] = w->id; | |
| 21680 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 794 times.
|
798 | if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family; |
| 21681 | 4 | else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1; | |
| 21682 | 798 | e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem; | |
| 21683 | 798 | e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID(); | |
| 21684 | |||
| 21685 | 798 | } | |
| 21686 | //we may need to handle this in special cases. -Z | ||
| 21687 | |||
| 21688 | //if h == stun or ignore | ||
| 21689 | |||
| 21690 | //if e->stun > DEFAULT_STUN -1 || !e->stun | ||
| 21691 | //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this | ||
| 21692 | ///! how about: if w->dead != bounce ! | ||
| 21693 | |||
| 21694 | // NOT FOR PUBLIC RELEASE | ||
| 21695 | /*if(h==3) //Mirror shield | ||
| 21696 | { | ||
| 21697 | if (w->id==ewFireball || w->id==wRefFireball) | ||
| 21698 | { | ||
| 21699 | w->id=wRefFireball; | ||
| 21700 | switch(e->dir) | ||
| 21701 | { | ||
| 21702 | case up: e->angle += (PI - e->angle) * 2.0; break; | ||
| 21703 | case down: e->angle = -e->angle; break; | ||
| 21704 | case left: e->angle += ((-PI/2) - e->angle) * 2.0; break; | ||
| 21705 | case right: e->angle += (( PI/2) - e->angle) * 2.0; break; | ||
| 21706 | // TODO: the following. -L. | ||
| 21707 | case l_up: break; | ||
| 21708 | case r_up: break; | ||
| 21709 | case l_down: break; | ||
| 21710 | case r_down: break; | ||
| 21711 | } | ||
| 21712 | } | ||
| 21713 | else | ||
| 21714 | { | ||
| 21715 | w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam); | ||
| 21716 | w->dir ^= 1; | ||
| 21717 | if(w->dir&2) | ||
| 21718 | w->flip ^= 1; | ||
| 21719 | else | ||
| 21720 | w->flip ^= 2; | ||
| 21721 | } | ||
| 21722 | w->ignoreHero=false; | ||
| 21723 | } | ||
| 21724 | else*/ | ||
| 21725 |
2/2✓ Branch 0 taken 1578 times.
✓ Branch 1 taken 869 times.
|
2447 | if(h) |
| 21726 | { | ||
| 21727 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 869 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
869 | if(e->switch_hooked && w->family_class == itype_switchhook) |
| 21728 | ✗ | w->onhit(false, e, -1); | |
| 21729 | 869 | else w->onhit(false, e, h); | |
| 21730 | 869 | } | |
| 21731 | |||
| 21732 |
2/2✓ Branch 0 taken 2431 times.
✓ Branch 1 taken 16 times.
|
2447 | if(h==2) |
| 21733 | { | ||
| 21734 | 16 | break; | |
| 21735 | } | ||
| 21736 | 2431 | } | |
| 21737 | |||
| 21738 |
2/2✓ Branch 0 taken 101538 times.
✓ Branch 1 taken 389 times.
|
101927 | if(w->Dead()) |
| 21739 | { | ||
| 21740 | 389 | break; | |
| 21741 | } | ||
| 21742 | 101538 | } | |
| 21743 | |||
| 21744 | // Item flags added in 2.55: | ||
| 21745 | // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP) | ||
| 21746 | // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT) | ||
| 21747 | // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT) | ||
| 21748 | // -Em | ||
| 21749 |
6/6✓ Branch 0 taken 69994 times.
✓ Branch 1 taken 19576 times.
✓ Branch 2 taken 69422 times.
✓ Branch 3 taken 572 times.
✓ Branch 4 taken 650 times.
✓ Branch 5 taken 68772 times.
|
89570 | if(w->id == wBrang || w->id == wHookshot || w->id == wArrow) |
| 21750 | { | ||
| 21751 | 20798 | int32_t itype, pitem = w->parentitem; | |
| 21752 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 19576 times.
✓ Branch 2 taken 650 times.
✓ Branch 3 taken 572 times.
|
20798 | switch(w->id) |
| 21753 | { | ||
| 21754 | 19576 | case wBrang: itype = itype_brang; break; | |
| 21755 | 650 | case wArrow: itype = itype_arrow; break; | |
| 21756 | case wHookshot: | ||
| 21757 | 572 | itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot); | |
| 21758 | 572 | break; | |
| 21759 | } | ||
| 21760 |
1/2✓ Branch 0 taken 20798 times.
✗ Branch 1 not taken.
|
20798 | if(pitem < 0) pitem = current_item_id(itype); |
| 21761 |
3/6✓ Branch 0 taken 572 times.
✓ Branch 1 taken 20226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 572 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
20798 | if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9)) |
| 21762 | { //Swap with item | ||
| 21763 | ✗ | for(int32_t j=0; j<items.Count(); j++) | |
| 21764 | { | ||
| 21765 | ✗ | if(items.spr(j)->hit(w)) | |
| 21766 | { | ||
| 21767 | ✗ | item *theItem = ((item*)items.spr(j)); | |
| 21768 | ✗ | bool priced = theItem->PriceIndex >-1; | |
| 21769 | ✗ | bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey; | |
| 21770 | ✗ | if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32) | |
| 21771 | ✗ | || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY)))) | |
| 21772 | { | ||
| 21773 | ✗ | if(!Hero.switchhookclk) | |
| 21774 | { | ||
| 21775 | ✗ | hooked_combopos = -1; | |
| 21776 | ✗ | hooked_layerbits = 0; | |
| 21777 | ✗ | switching_object = theItem; | |
| 21778 | ✗ | theItem->switch_hooked = true; | |
| 21779 | ✗ | w->misc = 2; | |
| 21780 | ✗ | w->step = 0; | |
| 21781 | ✗ | theItem->clk2=256; | |
| 21782 | ✗ | Hero.doSwitchHook(game->get_switchhookstyle()); | |
| 21783 | ✗ | if(QMisc.miscsfx[sfxSWITCHED]) | |
| 21784 | ✗ | sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x)); | |
| 21785 | ✗ | } | |
| 21786 | ✗ | } | |
| 21787 | ✗ | } | |
| 21788 | ✗ | } | |
| 21789 | ✗ | } | |
| 21790 |
6/6✓ Branch 0 taken 650 times.
✓ Branch 1 taken 20148 times.
✓ Branch 2 taken 4349 times.
✓ Branch 3 taken 3699 times.
✓ Branch 4 taken 20148 times.
✓ Branch 5 taken 3699 times.
|
20798 | else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items" |
| 21791 | { | ||
| 21792 |
2/2✓ Branch 0 taken 925 times.
✓ Branch 1 taken 4349 times.
|
5274 | for(int32_t j=0; j<items.Count(); j++) |
| 21793 | { | ||
| 21794 |
2/2✓ Branch 0 taken 899 times.
✓ Branch 1 taken 26 times.
|
925 | if(items.spr(j)->hit(w)) |
| 21795 | { | ||
| 21796 | 26 | item *theItem = ((item*)items.spr(j)); | |
| 21797 | 26 | bool priced = theItem->PriceIndex >-1; | |
| 21798 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
|
26 | bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey; |
| 21799 |
4/8✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 8 times.
|
34 | if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32) |
| 21800 |
4/6✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
|
26 | || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced))) |
| 21801 | { | ||
| 21802 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
34 | if(itemsbuf[theItem->id].collect_script) |
| 21803 | { | ||
| 21804 | ✗ | ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF); | |
| 21805 | ✗ | } | |
| 21806 | |||
| 21807 | 18 | Hero.checkitems(j); | |
| 21808 | 18 | } | |
| 21809 | 26 | } | |
| 21810 | 925 | } | |
| 21811 | 4349 | } | |
| 21812 |
2/2✓ Branch 0 taken 94 times.
✓ Branch 1 taken 16355 times.
|
23847 | else if(w->id!=wArrow) //A BRang/HShot with "Drags Items" |
| 21813 | { | ||
| 21814 |
2/2✓ Branch 0 taken 3305 times.
✓ Branch 1 taken 16355 times.
|
19660 | for(int32_t j=0; j<items.Count(); j++) |
| 21815 | { | ||
| 21816 |
2/2✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 944 times.
|
3305 | if(items.spr(j)->hit(w)) |
| 21817 | { | ||
| 21818 | 944 | item *theItem = ((item*)items.spr(j)); | |
| 21819 | 944 | bool priced = theItem->PriceIndex >-1; | |
| 21820 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 944 times.
|
944 | bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey; |
| 21821 |
4/6✓ Branch 0 taken 944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 944 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 904 times.
✓ Branch 5 taken 40 times.
|
944 | if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32) |
| 21822 |
5/10✓ Branch 0 taken 589 times.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 355 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 355 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 355 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
944 | || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY)))) |
| 21823 | { | ||
| 21824 | 589 | int32_t pickup = theItem->pickup; | |
| 21825 | 589 | int32_t id2 = theItem->id; | |
| 21826 | 589 | int32_t pstr = theItem->pstring; | |
| 21827 | 589 | int32_t pstr_flags = theItem->pickup_string_flags; | |
| 21828 | |||
| 21829 | 589 | std::vector<int32_t> &ev = FFCore.eventData; | |
| 21830 | 589 | ev.clear(); | |
| 21831 | 589 | ev.push_back(id2*10000); | |
| 21832 | 589 | ev.push_back(pickup*10000); | |
| 21833 | 589 | ev.push_back(pstr*10000); | |
| 21834 | 589 | ev.push_back(pstr_flags*10000); | |
| 21835 | 589 | ev.push_back(0); | |
| 21836 | 589 | ev.push_back(theItem->getUID()); | |
| 21837 | 589 | ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000); | |
| 21838 | 589 | ev.push_back(w->getUID()); | |
| 21839 | |||
| 21840 | 589 | throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM); | |
| 21841 | 589 | bool nullify = ev[4] != 0; | |
| 21842 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
|
589 | if(nullify) continue; |
| 21843 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
|
589 | if(w->id == wBrang) |
| 21844 | { | ||
| 21845 | 589 | w->onhit(false); | |
| 21846 | 589 | } | |
| 21847 | |||
| 21848 |
2/2✓ Branch 0 taken 552 times.
✓ Branch 1 taken 37 times.
|
589 | if(w->dragging==-1) |
| 21849 | { | ||
| 21850 | 37 | w->dead=1; | |
| 21851 | 37 | theItem->clk2=256; | |
| 21852 | 37 | w->dragging=j; | |
| 21853 | 37 | theItem->is_dragged = true; | |
| 21854 | 37 | } | |
| 21855 | 589 | } | |
| 21856 | 944 | } | |
| 21857 | 3305 | } | |
| 21858 | 16355 | } | |
| 21859 | 20798 | } | |
| 21860 | 89570 | } | |
| 21861 | 145379 | } | |
| 21862 | 783596 | void check_collisions() | |
| 21863 | { | ||
| 21864 |
2/2✓ Branch 0 taken 145366 times.
✓ Branch 1 taken 783596 times.
|
928962 | for(uint q = 0; q < Lwpns.Count(); ++q) |
| 21865 | 145366 | check_enemy_lweapon_collision((weapon*)Lwpns.spr(q)); | |
| 21866 | 783596 | } | |
| 21867 | |||
| 21868 | 783670 | void dragging_item() | |
| 21869 | { | ||
| 21870 |
2/2✓ Branch 0 taken 149960 times.
✓ Branch 1 taken 783670 times.
|
933630 | for(int32_t i=0; i<Lwpns.Count(); i++) |
| 21871 | { | ||
| 21872 | 149960 | weapon *w = (weapon*)Lwpns.spr(i); | |
| 21873 | |||
| 21874 |
4/4✓ Branch 0 taken 130016 times.
✓ Branch 1 taken 19944 times.
✓ Branch 2 taken 133275 times.
✓ Branch 3 taken 16685 times.
|
149960 | if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT |
| 21875 | { | ||
| 21876 |
3/4✓ Branch 0 taken 585 times.
✓ Branch 1 taken 16100 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 585 times.
|
16685 | if(w->dragging>=0 && w->dragging<items.Count()) |
| 21877 | { | ||
| 21878 | 585 | item* dragItem = (item*)items.spr(w->dragging); | |
| 21879 | 585 | dragItem->x=w->x; | |
| 21880 | 585 | dragItem->y=w->y; | |
| 21881 | |||
| 21882 | // Drag the Fairy enemy as well as the Fairy item | ||
| 21883 | 585 | int32_t id = dragItem->id; | |
| 21884 | |||
| 21885 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
585 | if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3) |
| 21886 | { | ||
| 21887 | ✗ | movefairynew2(w->x,w->y,*dragItem); | |
| 21888 | ✗ | } | |
| 21889 | 585 | } | |
| 21890 | 16685 | } | |
| 21891 | 149960 | } | |
| 21892 | 783670 | } | |
| 21893 | |||
| 21894 | 8 | int32_t more_carried_items() | |
| 21895 | { | ||
| 21896 | 8 | int32_t hasmorecarries = 0; | |
| 21897 | |||
| 21898 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 8 times.
|
18 | for(int32_t i=0; i<items.Count(); i++) |
| 21899 | { | ||
| 21900 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
|
10 | if(((item*)items.spr(i))->pickup & ipENEMY) |
| 21901 | { | ||
| 21902 | 8 | hasmorecarries++; | |
| 21903 | 8 | } | |
| 21904 | 10 | } | |
| 21905 | |||
| 21906 | 8 | return hasmorecarries; | |
| 21907 | } | ||
| 21908 | |||
| 21909 | // messy code to do the enemy-carrying-the-item thing | ||
| 21910 | 783670 | void roaming_item() | |
| 21911 | { | ||
| 21912 |
4/4✓ Branch 0 taken 1915 times.
✓ Branch 1 taken 781755 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 1907 times.
|
783670 | if(!(hasitem&(4|2)) || !loaded_enemies) |
| 21913 | 781763 | return; | |
| 21914 | |||
| 21915 | // All enemies already dead upon entering a room? | ||
| 21916 |
1/2✓ Branch 0 taken 1907 times.
✗ Branch 1 not taken.
|
1907 | if(guys.Count()==0) |
| 21917 | { | ||
| 21918 | ✗ | return; | |
| 21919 | } | ||
| 21920 | |||
| 21921 | // Lost track of the carrier? | ||
| 21922 |
3/6✓ Branch 0 taken 1907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1907 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1907 times.
✗ Branch 5 not taken.
|
1907 | if(guycarryingitem<0 || guycarryingitem>=guys.Count() || |
| 21923 | 1907 | !((enemy*)guys.spr(guycarryingitem))->itemguy) | |
| 21924 | { | ||
| 21925 | ✗ | guycarryingitem=-1; | |
| 21926 | ✗ | for(int32_t j=0; j<guys.Count(); j++) | |
| 21927 | { | ||
| 21928 | ✗ | if(((enemy*)guys.spr(j))->itemguy) | |
| 21929 | { | ||
| 21930 | ✗ | guycarryingitem=j; | |
| 21931 | ✗ | break; | |
| 21932 | } | ||
| 21933 | ✗ | } | |
| 21934 | ✗ | } | |
| 21935 | |||
| 21936 |
2/2✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 8 times.
|
1907 | if(hasitem&4) |
| 21937 | { | ||
| 21938 | 8 | guycarryingitem = -1; | |
| 21939 | |||
| 21940 |
2/2✓ Branch 0 taken 39 times.
✓ Branch 1 taken 8 times.
|
47 | for(int32_t i=0; i<guys.Count(); i++) |
| 21941 | { | ||
| 21942 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8 times.
|
39 | if(((enemy*)guys.spr(i))->itemguy) |
| 21943 | { | ||
| 21944 | 8 | guycarryingitem = i; | |
| 21945 | 8 | } | |
| 21946 | 39 | } | |
| 21947 | |||
| 21948 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | if(guycarryingitem == -1) //This happens when "default enemies" such as |
| 21949 | { | ||
| 21950 | ✗ | return; //eSHOOTFBALL are alive but enemies from the list | |
| 21951 | } //are not. Defer to HeroClass::checkspecial(). | ||
| 21952 | |||
| 21953 | 8 | int32_t Item=tmpscr->item; | |
| 21954 | |||
| 21955 | 8 | hasitem &= ~4; | |
| 21956 | |||
| 21957 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
|
8 | if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0)) |
| 21958 | { | ||
| 21959 | 16 | additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE | |
| 21960 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0) |
| 21961 | ); | ||
| 21962 | 8 | hasitem |= 2; | |
| 21963 | 8 | } | |
| 21964 | else | ||
| 21965 | { | ||
| 21966 | ✗ | return; | |
| 21967 | } | ||
| 21968 | 8 | } | |
| 21969 | |||
| 21970 |
2/2✓ Branch 0 taken 1989 times.
✓ Branch 1 taken 1907 times.
|
3896 | for(int32_t i=0; i<items.Count(); i++) |
| 21971 | { | ||
| 21972 |
2/2✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1907 times.
|
1989 | if(((item*)items.spr(i))->pickup&ipENEMY) |
| 21973 | { | ||
| 21974 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1907 times.
|
1907 | if(get_qr(qr_HIDECARRIEDITEMS)) |
| 21975 | { | ||
| 21976 | ✗ | items.spr(i)->x = -128; // Awfully inelegant, innit? | |
| 21977 | ✗ | items.spr(i)->y = -128; | |
| 21978 | ✗ | } | |
| 21979 |
2/4✓ Branch 0 taken 1907 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1907 times.
|
1907 | else if(guycarryingitem>=0 && guycarryingitem<guys.Count()) |
| 21980 | { | ||
| 21981 |
1/2✓ Branch 0 taken 1907 times.
✗ Branch 1 not taken.
|
1907 | if (!get_qr(qr_BROKEN_ITEM_CARRYING)) |
| 21982 | { | ||
| 21983 | ✗ | if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS)) | |
| 21984 | { | ||
| 21985 | ✗ | items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8; | |
| 21986 | ✗ | items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10; | |
| 21987 | ✗ | } | |
| 21988 | else | ||
| 21989 | { | ||
| 21990 | ✗ | if(guys.spr(guycarryingitem)->extend >= 3) | |
| 21991 | { | ||
| 21992 | ✗ | items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8; | |
| 21993 | ✗ | items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8; | |
| 21994 | ✗ | } | |
| 21995 | else | ||
| 21996 | { | ||
| 21997 | ✗ | items.spr(i)->x = guys.spr(guycarryingitem)->x; | |
| 21998 | ✗ | items.spr(i)->y = guys.spr(guycarryingitem)->y - 2; | |
| 21999 | } | ||
| 22000 | } | ||
| 22001 | ✗ | items.spr(i)->z = guys.spr(guycarryingitem)->z; | |
| 22002 | ✗ | items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez; | |
| 22003 | ✗ | } | |
| 22004 | else | ||
| 22005 | { | ||
| 22006 | 1907 | items.spr(i)->x = guys.spr(guycarryingitem)->x; | |
| 22007 | 1907 | items.spr(i)->y = guys.spr(guycarryingitem)->y - 2; | |
| 22008 | 1907 | items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez; | |
| 22009 | } | ||
| 22010 | 1907 | } | |
| 22011 | 1907 | } | |
| 22012 | 1989 | } | |
| 22013 | 783670 | } | |
| 22014 | |||
| 22015 | ✗ | bool enemy::IsBigAnim() | |
| 22016 | { | ||
| 22017 | ✗ | return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB | |
| 22018 | ✗ | || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB | |
| 22019 | ✗ | || anim == a4FRM8DIRB); | |
| 22020 | } | ||
| 22021 | 56627 | int32_t enemy::getFlashingCSet() | |
| 22022 | { | ||
| 22023 | //Special cset for the dying sprite | ||
| 22024 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 56627 times.
|
56627 | if(dying) |
| 22025 | { | ||
| 22026 | ✗ | if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof) | |
| 22027 | ✗ | return wpnsbuf[spr_death].csets & 15; | |
| 22028 | else | ||
| 22029 | ✗ | return (((clk2 + 5) >> 1) & 3) + 6; | |
| 22030 | } | ||
| 22031 | |||
| 22032 | //Normal cset | ||
| 22033 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 56627 times.
|
56627 | if (hclk <= 0) |
| 22034 | { | ||
| 22035 | //Special cset for the flashing animation | ||
| 22036 | ✗ | if (flags2 & guy_flashing) | |
| 22037 | ✗ | return (frame & 3) + 6; | |
| 22038 | ✗ | return cs; | |
| 22039 | } | ||
| 22040 | |||
| 22041 | //Hurt animations | ||
| 22042 |
2/2✓ Branch 0 taken 324 times.
✓ Branch 1 taken 56303 times.
|
56627 | if(family==eeGANON) |
| 22043 | 324 | return (((hclk-1)>>1)&3)+6; | |
| 22044 |
4/4✓ Branch 0 taken 51730 times.
✓ Branch 1 taken 4573 times.
✓ Branch 2 taken 1004 times.
✓ Branch 3 taken 50726 times.
|
56303 | else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER)) |
| 22045 | 50726 | return (((hclk-1)>>1)&3)+6; | |
| 22046 | |||
| 22047 | 5577 | return cs; | |
| 22048 | 56627 | } | |
| 22049 | |||
| 22050 | 1836174 | bool enemy::is_hitflickerframe(bool olddrawing) | |
| 22051 | { | ||
| 22052 |
6/6✓ Branch 0 taken 1833210 times.
✓ Branch 1 taken 2964 times.
✓ Branch 2 taken 106201 times.
✓ Branch 3 taken 1727009 times.
✓ Branch 4 taken 104218 times.
✓ Branch 5 taken 1983 times.
|
1836174 | if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER)) |
| 22053 | 1834191 | return false; | |
| 22054 | |||
| 22055 |
3/4✓ Branch 0 taken 1145 times.
✓ Branch 1 taken 838 times.
✓ Branch 2 taken 1145 times.
✗ Branch 3 not taken.
|
1983 | if (!olddrawing && !getCanFlicker()) |
| 22056 | ✗ | return false; | |
| 22057 | |||
| 22058 | 1983 | int32_t fr = game->get_spriteflickerspeed(); | |
| 22059 |
1/2✓ Branch 0 taken 1983 times.
✗ Branch 1 not taken.
|
1983 | if (fr == 0) |
| 22060 | ✗ | return true; | |
| 22061 | 1983 | return frame % (fr * 2) < fr; | |
| 22062 | 1836174 | } | |
| 22063 | |||
| 22064 | const char *old_guy_string[OLDMAXGUYS] = | ||
| 22065 | { | ||
| 22066 | "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","", | ||
| 22067 | // 020 | ||
| 22068 | "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)", | ||
| 22069 | // 025 | ||
| 22070 | "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)", | ||
| 22071 | // 030 | ||
| 22072 | "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock", | ||
| 22073 | // 035 | ||
| 22074 | "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)", | ||
| 22075 | // 040 | ||
| 22076 | "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)", | ||
| 22077 | // 045 | ||
| 22078 | "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)", | ||
| 22079 | // 050 | ||
| 22080 | "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo", | ||
| 22081 | // 055 | ||
| 22082 | "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm", | ||
| 22083 | // 060 | ||
| 22084 | "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)", | ||
| 22085 | // 065 | ||
| 22086 | "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)", | ||
| 22087 | // 070 | ||
| 22088 | "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)", | ||
| 22089 | // 075 | ||
| 22090 | "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)", | ||
| 22091 | // 080 | ||
| 22092 | "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ", | ||
| 22093 | // 085 | ||
| 22094 | "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)", | ||
| 22095 | // 090 | ||
| 22096 | "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)", | ||
| 22097 | // 095 | ||
| 22098 | "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)", | ||
| 22099 | // 100 | ||
| 22100 | "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)", | ||
| 22101 | // 105 | ||
| 22102 | "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)", | ||
| 22103 | // 110 | ||
| 22104 | "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)", | ||
| 22105 | // 115 | ||
| 22106 | "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)", | ||
| 22107 | // 120 | ||
| 22108 | "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ", | ||
| 22109 | // 125 | ||
| 22110 | "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ", | ||
| 22111 | // 130 | ||
| 22112 | "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ", | ||
| 22113 | // 135 | ||
| 22114 | "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)", | ||
| 22115 | // 140 | ||
| 22116 | "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ", | ||
| 22117 | // 145 | ||
| 22118 | "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ", | ||
| 22119 | // 150 | ||
| 22120 | "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)", | ||
| 22121 | // 155 | ||
| 22122 | "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)", | ||
| 22123 | // 160 | ||
| 22124 | "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)", | ||
| 22125 | // 165 | ||
| 22126 | "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ", | ||
| 22127 | // 170 | ||
| 22128 | "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ", | ||
| 22129 | // 175 | ||
| 22130 | "Grappler Bug (HP) ", "Grappler Bug (MP) " | ||
| 22131 | }; | ||
| 22132 |